[SDL] Re: SDL Digest, Vol 11, Issue 32
alex00882007 at gmail.com
Mon Mar 28 16:37:24 PST 2005
On Friday 11 March 2005 12.23, Jonas Huckestein wrote:
> thanks david :)
> On Friday 11 March 2005 09:02, David Olofson wrote:
> > Because of the complexity that adds, and other, more serious
> > issues (collision detection and event handling), I generally
> > prefer to use a fixed logic frame rate for totally concistent
> > behavior.
> yea, that's what i was thinking. so how would i do that then?
> simply skip a few rounds on my game-loop or do any problems come
> with that?
That's basically it. You decide on a nominal frame rate for your game
logic, and then you design all logic code as if that was the frame
rate of the game - like in the old days, when you'd normally
hard-sync the whole game to the display refresh rate. (Which was/is
either 50 or 60 Hz on devices made to be used with a TV set.) Then
you implement some logic to run the game logic at that *average*
frame rate, with a (sort of) asynchronous relation to the rendering
Note that you'll need to be able to do both more and less than one
logic frame per rendered frame! If you decide on 100 Hz logic rate
for example, you'll need to handle both lower and higher rendering
The next stage is optional, but rather nice: Implement interpolation
of all coordinates extracted from the logic code. That is, if logic
time turns out to be halfway between two logic frames when it's time
to render, interpolate over the output from last two logic frames you
have, rather than just using the last one.
Have a look at my Fixed Rate Pig example, which demonstrates "ultra
smooth" animation while using a very low, fixed logic frame rate:
(Or look at Kobo Deluxe, which uses the same technique - though I
suspect you won't find that code as friendly to study. ;-)
> (theres this sdl_framerate thingy from the sdl_gfx package and i was
> wondering why that is necessary at all)
Haven't looked that close at it, but I'd guess it's just a handy tool
for measuring and/or throttling the frame rate, and/or for doing
these frame delta time calculations we all do one way or another...
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
--- http://olofson.net --- http://www.reologica.se ---
More information about the SDL