[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] kind of animation



My animation is time based.  Only after so many ticks will the frame change.

Each sprite has an image file and all the different animations are in it, all laid out in a strip.  I setup a dictionary with a name key that points to a list of frames to cycle through, ie:  self.animations = {'left':[1,2,3],'right':[4,2,5]}

Nothing fancy but it works and it's flexible.



On 5/15/06, DR0ID < dr0id@xxxxxxxxxx> wrote:
Hello everybody

I want to implement some animation and came up with 3 different ways to
do that:

1. frame based animation

2. time based animation

3. event based animation

Well 1. one is clear: on each frame the animation is advanced one image.
Simple to implement, but on different machines it runs with different
speeds ( although you slow it down to a fix framerate).

The 2. one is a bit different: on each frame the time is passed and the
animation is only davanced if the time for an image has passed by. On
different computers it should run equaly fast, not depending on the
framerate (because it depends on time).

And the 3. one only advances the animation if an event is received. Ok,
doesent look practical but in combination with a timer perhaps it could.
Or if one wants to make the animation depending on user action.


I wonder in wich way you do your animations. As said, I think framebased
is the simplest thing to do, but perhaps not the best. And perhaps there
are other ways to do animation!? There is also the other question: how
to store the images for the animation. A list of images? Or one big
image strip and then only changing the source rect? Or a list of
sprites? What if an object uses 4 different animations? Use 4 lists in a
dict? Or a list of animation-objects? Or an 2D-image strip and move the
source rect?

You see I have some questions. :-)


~DR0ID