Created
February 27, 2023 03:03
-
-
Save OMAR-3OOV/a42dcd78cc759ef8880d3c178151932c to your computer and use it in GitHub Desktop.
Animation circle that gives a different colors and spend around the player as a circle and move up and down
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun animateParticles(player: Player) { | |
val particleType = Particle.REDSTONE | |
val colors1 = arrayOf( | |
Color.fromRGB(247,202,201), Color.fromRGB(222,194,203), Color.fromRGB(197,185,205), | |
Color.fromRGB(171,177,207), Color.fromRGB(146,168,209) | |
) | |
val radius = 1.0 // radius of the pentagon | |
val period = 80L // time for one full rotation (in ticks) | |
object : BukkitRunnable() { | |
var theta = 0.0 | |
var colorIndex = 0 | |
override fun run() { | |
// Update theta based on current time | |
theta = ((theta + Math.PI / period) % (2 * Math.PI)) | |
// Get player location and add y-offset | |
val loc = player.location.add(0.0, 1.0, 0.0) | |
// Calculate particle positions for pentagon | |
val x1 = radius * cos(theta) | |
val z1 = radius * sin(theta) | |
val x2 = radius * cos(theta + 2 * Math.PI / 6) | |
val z2 = radius * sin(theta + 2 * Math.PI / 6) | |
val x3 = radius * cos(theta + 4 * Math.PI / 6) | |
val z3 = radius * sin(theta + 4 * Math.PI / 6) | |
val x4 = radius * cos(theta + 6 * Math.PI / 6) | |
val z4 = radius * sin(theta + 6 * Math.PI / 6) | |
val x5 = radius * cos(theta + 8 * Math.PI / 6) | |
val z5 = radius * sin(theta + 8 * Math.PI / 6) | |
val x6 = radius * cos(theta + 10 * Math.PI / 6) | |
val z6 = radius * sin(theta + 10 * Math.PI / 6) | |
val yOffset = 0.5 * sin(theta * 2) | |
// Cycle through colors in array | |
val color1 = colors1[colorIndex] | |
colorIndex = (colorIndex + 1) % colors1.size | |
// Spawn particles at pentagon positions | |
player.spawnParticle(particleType, loc.clone().add(x1, yOffset, z1), 0, Particle.DustOptions(color1, 1f)) | |
player.spawnParticle(particleType, loc.clone().add(x2, yOffset, z2), 0, Particle.DustOptions(color1, 1f)) | |
player.spawnParticle(particleType, loc.clone().add(x3, yOffset, z3), 0, Particle.DustOptions(color1, 1f)) | |
player.spawnParticle(particleType, loc.clone().add(x4, yOffset, z4), 0, Particle.DustOptions(color1, 1f)) | |
player.spawnParticle(particleType, loc.clone().add(x5, yOffset, z5), 0, Particle.DustOptions(color1, 1f)) | |
player.spawnParticle(particleType, loc.clone().add(x6, yOffset, z6), 0, Particle.DustOptions(color1, 1f)) | |
} | |
}.runTaskTimerAsynchronously(Main.getInstance(), 0L, 1L) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment