I'm new to Game programmming and SDL, and I have been following Lazyfoo's SDL tutorials. My question is related to time based motion and frame rate based motion, basically which is better or appropriate depending on situations?. Could you give me an example where each of these methods are used?.

Another question I have is that, in lazyfoo's two Motion tutorials (FPS based and time based) The time based method showed a much smoother animation while the Frame rate based one was a little hiccupy, meaning you could clearly see the gap between the previous location of the dot and its current position when you compare the two programs.

As beginner which method should I stick to?(all I want is smooth animations).


1 Answer 1


What's being shown as "FPS based" there is . . . well, basically, it's awful. It's pinning the game's speed to the performance of one particular computer. If you upgrade to a nice fast computer, your game will suddenly run in turbo speed, if you downgrade to a slower computer you'll be grinding around in slo-mo.

The real choice is fixed time step vs. variable time step, and at that point I will defer to this excellent post which goes into great depth.

  • \$\begingroup\$ Not only will things move fast or slow depending on the computer it is running, but all animations will move at the same rate - what that means is that some animations will run super fast, while some run a bit slower, making it look really odd. \$\endgroup\$ Commented Dec 27, 2010 at 0:07
  • \$\begingroup\$ but isn't capping the frame rate going to account for this? \$\endgroup\$
    – silent
    Commented Dec 27, 2010 at 2:34
  • \$\begingroup\$ @sil3nt, only until you're running on someone with an unexpectedly slow computer, or until you start using enough CPU to drop below your framerate cap. \$\endgroup\$
    – ZorbaTHut
    Commented Dec 28, 2010 at 8:56
  • \$\begingroup\$ So then the frame rate based method is fine if the computer that the program is running on can handle the FPS? \$\endgroup\$
    – silent
    Commented Dec 29, 2010 at 4:48
  • \$\begingroup\$ @sil3nt, yes, if you can guarantee the computer can always handle the FPS, and you have a reliable way to lock to that framerate. This is enough qualifiers that I'd be very hesitant to use it, especially with how simple fixed time step is. \$\endgroup\$
    – ZorbaTHut
    Commented Dec 30, 2010 at 23:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .