Search - User list
Full Version: Assigning flapping birds to sprites
Root » Technical Discussion » Assigning flapping birds to sprites
Jostein


Hiya mates!

I had a thorough look at the butterfly sprite tutorials … but I have a problem cycling my flapping-textures.

Suggestion: What if I assign each sprite a cycle (with a randomised offset given it at birth) and then go through npoints for each frame and cycle the texture assigned to each sprite?

Any thoughts?

Cheers, Jostein.
Antoine Durr
Jostein


Hiya mates!

I had a thorough look at the butterfly sprite tutorials … but I have a problem cycling my flapping-textures.

Suggestion: What if I assign each sprite a cycle (with a randomised offset given it at birth) and then go through npoints for each frame and cycle the texture assigned to each sprite?

Any thoughts?

Cheers, Jostein.

Modulo is at the heart of cycling, e.g.

$F%12

Assuming a 12 frame cycle, you'll get values 0 -> 11 out of it. Then, just add some offset:

($F+34)%12

Typically, if you have a bunch of objects, all doing the same thing, you can use opdigits(), as in:

($F+opdigits(“..”))%12

However, that only puts them at one frame appart each, so instead, refine the expression to:

($F+int(fit(rand(opdigits(“..”)),0,1,0,12)%12

That way, the rand() is essentially generating a random value that's zero to number-of-frames-in-cycle.

– Antoine
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.