Assigning flapping birds to sprites

   3057   1   2
User Avatar
Member
6 posts
Joined: July 2005
Offline


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.
User Avatar
Member
321 posts
Joined: July 2005
Offline
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
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
  • Quick Links