Understanding the Game Loop
Explore how the game loop functions within a Rust-based game. Understand its key steps including input polling, calling the tick function for gameplay, updating the screen, and handling exit conditions. This lesson helps you grasp how continuous game mechanics are managed in a smooth, efficient manner using bracket-lib.
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 ...