Game Palette: Timing demo

This browser does not support HTML5 canvas; it is required to use the Game Palette library


The engine runs the logic function desiredFPS times a second. The top UFO moves 4 pixels each step, so its speed changes with the number of steps. The bottom one moves 120 pixels a second, which is 120 / desiredFPS pixels a step, so it keeps the same speed however many steps there are; it just moves more smoothly with more of them. Both UFOs' lights are animations, which play by the clock, so they never change speed.

"Slow computer" makes each step waste time, as a game with too much to do would. Once the steps can't keep up, the engine runs several steps before each redraw (so the picture is redrawn less often than the steps are run), and when even that isn't enough, the game slows down: the game clock falls behind the real one, and both UFOs slow down, but the animations don't. The readout shows actualLogicFPS and actualVisualFPS, as a game can to check how it's doing.

See desiredFPS and actualLogicFPS and actualVisualFPS in the manual.

All demos