[SDL] animations etc

David Olofson david.olofson at reologica.se
Tue Sep 17 07:09:01 PDT 2002


On Tuesday 17 September 2002 15:33, Kylotan wrote:
> screwtape at froup.com wrote:
> > You have an event loop that you'll be iterating through quite
> > frequently, and you have a function to get a number which increases
> > at a constant rate in real time (as opposed to CPU time).
> >
> > All you need is a sorted list of happenings[1] and specified times -
> > for example, when you want a bomb to explode five seconds from now,
> > add a new happening to the list with the time 'SDL_GetTicks() + 5000'
> > (because SDL_GetTicks measures 1000 ticks per second).
>
> This can be awkward if you allow the player to pause the game. In such
> a situation, you will need to do something like time how long the game
> is paused (and add that to all the event times when the player
> unpauses) or time the events in frames instead.

In Kobo Deluxe, I'm using "logic frames" as the time base. Game logic is 
called at 33.33 Hz (on average - work is actually done once per video 
frame; no timers) regardless of rendering frame rate. Logic time is 
incremeted by 1.0 for every logic frame.

When the game is paused, I just stop advancing logic time, and as a 
result, the graphics/timing engine stops calling the game logic callback. 


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`-------------------------------------> http://olofson.net -'




More information about the SDL mailing list