To overcome this, the program would need to reduce the frame rate. Timing - How It's Really Done To explain how this is done, let's back up a bit and do some math and physics work. Speed x Time . In our program, Distance is measured in pixels, Time in milliseconds, and Speed in pixels per millisecond. However, rendering time varies significantly in the real world.
Different computers render at different speeds.
Also, one frame may be drawn faster or slower than the next based on factors such as the number of sprites and scene complexity. To deal with this, we need to start dealing with Time as a variable, and not as some arbitrary constant. This is the Zen Timer from Michael Abrash's Zen of Assembly Language Programming book. This type of accuracy is provided by the Zen library. The general idea for this version is that we will first discover the rendering time.