# Game Loop

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

**Field:** Software Development  
**Category:** Game Development  
**Also known as:** Main Loop, Update Loop, Game Tick

## Think of it like

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

## 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

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

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Delta Time](https://learn.benibix.com/term/development/delta-time)
- [Game Engine](https://learn.benibix.com/term/development/game-engine)
- [Loop](https://learn.benibix.com/term/development/loop)
- [Frame Rate](https://learn.benibix.com/term/design/frame-rate)
- [Event Loop](https://learn.benibix.com/term/development/event-loop)

![Three boxes in a loop: 1, read input from keys, mouse and touch; 2, update, lit up, move by speed times delta time; 3, draw one new frame; then back to the start, about 60 times a second. Below, a fast computer at 60 loops a second moves 200 times 1/60 of a second, 3.3 pixels per loop, and a slow computer at 30 loops a second moves 6.7 pixels per loop. A note says both move 200 pixels each second because each step uses delta time.](https://learn.benibix.com/diagrams/dev2-game-loop.svg)

---

Source: https://learn.benibix.com/term/development/game-loop
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
