Are timers not Independent of fps? (screenshots inside)

This is at the end a sampling theorem problem – your main loop doesn’t run at a perfect 60 Hz, and thus any timers will be quantized to when the main loop/tick happens to actually run.

The most accurate way to deal with this, is to get the current game time inside tick, and accumulate that to a variable. Then enter a loop that checks whether the variable is greater than 1/60, if so, subtract 1/60 from the variable, run your “one tick” function, and then check the loop again. If a particular frame takes longer to run, you’ll run your “one tick” function more than once in a single game loop tick.

3 Likes