Understanding the Game Loop
Learn the basic understanding of the game loop and its use in making games.
We'll cover the following
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 more than 60 times per second. On each pass through the loop, it calls the game’s tick()
function. Here’s a closer look at the game loop and what each step does:
Get hands-on with 1400+ tech skills courses.