Skip to content

Euler Integration (basic physics step)

Euler Integration (basic physics step)

function update(entity, dt):
    entity.velocity += entity.acceleration * dt
    entity.position += entity.velocity * dt

Euler integration is the simplest way to simulate motion: velocity changes by acceleration over a timestep, and position changes by velocity over that same timestep. It's an approximation (true motion under constant acceleration is a parabola, not a straight line per frame), but at typical frame rates the error is invisible. Always multiply by dt (delta time) rather than assuming a fixed frame rate — this keeps movement speed consistent regardless of framerate.