Game Dev

Game loop notes: fixed steps, smooth frames

This is an example article for the starter site. Replace it with a real devlog through the admin studio. A game loop is a useful first topic because it touches timing, input, simulation, and the feel of play.

Why a fixed step helps

Rendering can follow the display. Simulation needs a stable rhythm. When the time step changes with every frame, small differences accumulate and make movement or collision harder to reason about.

A simple loop tracks elapsed time, advances the simulation in fixed increments, then draws the latest state.

rust
let step = Duration::from_secs_f64(1.0 / 60.0); let mut accumulator = Duration::ZERO; loop { accumulator += frame_time(); while accumulator >= step { update_world(step); accumulator -= step; } render_world(); }

The edge cases matter

You still need to decide what happens when a frame takes much longer than expected. A clamp prevents the simulation from spending too long catching up. Input should be sampled deliberately so short presses do not disappear between updates.

  • Measure frame times during development.
  • Keep simulation state separate from visual interpolation.
  • Test behavior at slow and uneven frame rates.

What I would test next

Record an input sequence and replay it with different render frame rates. The same simulation result is a useful sign that the boundary between update and draw is doing its job.

END OF NOTEMore writing →