The central code loop responsible for handling the running gameplay. At its most basic state, it accepts input, resolves the actions of entities, and renders the scene.
The game loop is designed to ensure the persistence of action in a game. Unlike many other software applications, games do not stall and wait for input. The world continues to run while the player watches, which importantly allows timing to play a role.
The game loop is responsible for allowing this, by continually rendering the scene without requiring the player's input. A rudimentary game loop might run like the following:
- Accept player input if any exists, resolve actions for player as a result of any input
- Resolve AI decisions and actions
- Determine collisions and resolve their impact
- Render the resulting scene
Use this tag when you're asking questions such as the proper structure, optimization and efficiency strategies, or debugging errors in the main game loop code.