[SDL] Framerate and speed interpolation

Carlos Alvarez citrouille at wanadoo.fr
Mon Nov 24 11:48:01 PST 2003


The main problem you are facing is one that many people face. It is the
> belief in a constant frame rate. There is now such thing on modern
PCs.
> Forget about it. Sure, the hardware is running at a constant frame
rate,
> but your program may or may not be running at any given time. The
result
> is that you might as well just assume that the time between frames is
> random.
>
> Remember that velocity is distance/time you are trying to use
> frames/second as a valid time base, and it isn't working. So, use the
> real time. Just grab the time using SDL_getTicks(). and use:
>
> r.x += (distance * time) * cos(degrees_to_radiant(angle));
> r.y += (distance * time) * sin(degrees_to_radiant(angle));
>
> where the time is measured in milliseconds and the distance is
measured
> in pixels/millisecond. Doing it this way gives you a constant visual
> motion independent of when you get to draw the next screen.
>
> To say it again, the frame rate is not a usable time base on modern
> computers.
>
> Bob Pendleton
>

Can the motion angle be still affected by framerate (if no framerate
regulation) although speed is displayed as constant ?





More information about the SDL mailing list