[SDL] Delta time?
L-28C
kixdemp at gmail.com
Fri Oct 12 15:35:17 PDT 2007
Hello people of SDL!
I've been capping the framerate in my games the last few times, but I
want to give delta time a try... Here's the code I have modified to work
with DT:
-----------------------
oldTime = SDL_GetTicks();
while (1)
{
newTime = SDL_GetTicks();
delta = newTime - oldTime;
/* Update control status */
handleControls(controls);
/* TODO: Pause, not exit */
if (controls[K_PAUSE]) exit(0);
/* Process game logic */
doLogic(delta);
/* Render our scene */
renderBackground();
render(0);
/* So we don't use 100% CPU */
SDL_Delay(1);
oldTime = newTime;
}
-----------------------
In doLogic(), what I had done while capping FPS was add 0.05f to the
ball's speed (acceleration) and multiply by 0.99f (deceleration).
But how would I modify those values to work with my delta?
Thanks!
More information about the SDL
mailing list