[SDL] Framerate independence?
Patricia Curtis
patricia.curtis at gmail.com
Thu Mar 29 12:02:36 PDT 2007
Hi Guys
Why are you all worrying about deltas and how far your sprites will
move relative to the frame rate?, as i said in one of my previous posts,
just use a timer. The main loop can run flat out and draw everything. The
timer will run at a set interval (30fps) on slow or fast or blindingly fast
machines. This system works for me on dog slow machines the game runs at the
same speed, but the screen update in obviously much slower but even with
tricky sprite deltas that can not be fixed. Some of my games i use more than
one timer running at different speeds like one for animation, one for moving
one for game time count down etc......
// main loop
while(1)
{
DrawStuff
Draw More Stuff
Flip()
WaitFrameRate.
}
// some timer
Timer()
{
MoveStuff
MoveMoreStuff
CheckCollisions // do this here because thats where you moved it
AnimateStuff
}
Trish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070330/ccbe88fd/attachment.htm
More information about the SDL
mailing list