Skip to content
BENIBIX Learn

Delta Time

Development🎮 Game DevelopmentGame Basics

Also known as Frame Time, deltaTime, dt

How long the last frame took. Multiply moves by it to keep speed fair.

Think of it like

Think of it like walking by the clock, not by steps. You get there on time, fast legs or slow.

Example

Emma's car moves too fast on her new laptop. She multiplies the speed by delta time, and it is right on both.

Why it matters

Players have fast and slow computers. Delta time makes the game feel the same for all of them.

Definition

Delta time is how long the last frame took, often a tiny part of a second. Games multiply each move by it. So a car set to 200 pixels a second moves the same speed on a fast computer and a slow one. Without it, the game runs faster on faster machines. Engines hand it to your code on every pass of the loop.

Example code

python
speed = 200  # pixels per second
x += speed * dt
Multiply by dt, and the car moves 200 pixels each second on any computer.
The bottom row: different steps per loop, the same speed each second.

Common mistake

Moving things a fixed amount each frame. The game then runs at a different speed on each computer.

Key takeaways

  1. 1
    Time per frame. It is how long the last frame took.
  2. 2
    Multiply moves. Speed times delta time gives the step.
  3. 3
    Fair on all machines. The game runs at the same speed everywhere.