Skip to content
BENIBIX Learn

Game Loop

Development🎮 Game DevelopmentGame Basics

Also known as Main Loop, Update Loop, Game Tick

A loop that reads keys, moves things and draws the screen, over and over.

Think of it like

Think of it like a flip book. Each page moves a little, and flipping fast makes it move.

Example

In Jack's game, each pass of the loop checks the arrow keys, moves the car and draws the road again.

Why it matters

Everything in a game happens inside it. Knowing it explains why slow code makes a game stutter.

Definition

The game loop is the loop at the heart of every game. Over and over, it reads what the player pressed, moves everything a little, and draws a new frame. It runs many times a second, often about 60. Each pass is short, so the game feels smooth. The engine runs the loop, and your code runs inside each pass.

Example code

python
while running:
    read_input()
    update(dt)
    draw()
The game loop in four lines: read the keys, move things, draw, and go again.
The three steps of the loop, then back to the start.

Common mistake

Doing slow work inside the loop, like loading a file. Each pass must finish fast, or frames drop.

Key takeaways

  1. 1
    Input, update, draw. Each pass does the same three steps.
  2. 2
    Many times a second. Often about 60 passes each second.
  3. 3
    Keep it quick. A slow pass makes the game stutter.