...

/

Understanding the Game Loop

Understanding the Game Loop

Learn the basic understanding of the game loop and its use in making games.

The need for the game loop

The terminal-based programs we studied in previous lessons can operate and execute top-to-bottom through the main() function, pausing for user input. Most games won’t stop or pause whenever the player wants to press a key.

In Flappy Dragon, the player’s dragon continues to fall even if the player isn’t touching the keyboard. For games to operate smoothly, they instead run a game loop.

The game loop initializes windowing, graphics, and other resources. It runs every time the screen is refreshed, which is often 30, 60, or sometimes ...