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

RE: [pygame] kind of animation



To satisfy my own curiosity, what is the fundamental difference between
time-based and frame-based... Oh wait, never mind, I answered my own
question :D

To throw in my own two cents, why not use all three types of animation, that
way if you have three different animation "engines" available, you could
have a flag in a sprite class that defines which engine is pushing the
sprite at any given time. For example, a Space Invaders type-game would use
time-based animation (for the descending rows of aliens, which inevitably
speed up as more and more get destroyed), frame-based animation for the
flying saucer that randomly rolls across top of the screen, and event-based
animation for moving the player ship around.

-----Original Message-----
From: owner-pygame-users@xxxxxxxx [mailto:owner-pygame-users@xxxxxxxx]On
Behalf Of DR0ID
Sent: Wednesday, May 24, 2006 10:51
To: pygame-users@xxxxxxxx
Subject: Re: [pygame] kind of animation


Peter Shinners schrieb:
> On Mon, 2006-05-15 at 22:34 +0200, DR0ID wrote:
>   
>> 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
>>     
>
> I'd have to say go with time based animation. It's not really harder
> than frame based and you end up with a consistent game. I will offer the
> following tips:
>
> Keep all your times and positions as floating point values. This means
> you won't be able to store positions with pygame.Rect
>
> Pay attention when you have something that randomly happens each frame.
> You'll need to scale the odds of things happening by how long the frame
> took. A better approach is to randomly pick an amount of time for the
> next "event" to happen and wait for that. Then you could fire multiple
> events in a single frame if it took too long.
>
> There really isn't much in there to worry about. You'll need floating
> point positions anyways once you want something that moves slower than
> one pixel per frame.
>
>
>
>   
Hello

Thank you for your tips. I was more interessted in how and when change 
the image of an animation rather than moving it around. But your right, 
for the position one should use a float tuple because rect can only 
store integers.

I had planned to use rects for collision detection, but if I do, then I 
have to round my position coordinates to integers to use rect for that. 
I have to rethink that although I assume it makes not a big difference.

If I understand you right you suggest to make the objects and functions 
time dependent. What do you mean with "you end up with a consistent game"?

As said, I was more interested how to update the image of an animation. 
But this leads to a other question which I will ask in an other email.


~DR0ID
 




CONFIDENTIAL NOTICE: This email including any attachments, contains 
confidential information belonging to the sender. It may also be 
privileged or otherwise protected by work product immunity or other 
legal rules. This information is intended only for the use of the 
individual or entity named above.  If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, 
distribution or the taking of any action in reliance on the contents 
of this emailed information is strictly prohibited.  If you have 
received this email in error, please immediately notify us by 
reply email of the error and then delete this email immediately.