Game Loop

Definition
In video games, a control loop periodically updates the game. When the game is not being updated it is idle.
Game loop architecture diagram

How does it work?

In video games the positions of all moving objects needs to be updated, say 50 times per second, for animations to look smooth. For this reason they contain a timer that fires with this frequency. Each time the timer fires, inputs are processed, the game state is updated, and the new scene is rendered.

Examples

  • Videogames like Pac-man and Doom

When should you use it?

  • In games with fluid animations.

Problems

  • The updater function should be able to complete within 1/50th of a second.

Common implementation techniques

  • A simple timer will do. Each language has its own implementation.

Links