Lab · hands-on
The game loop live
Three objects move at the same nominal speed — but under three update strategies. Drop the render FPS, turn the simulation rate, switch interpolation on, hit "frame spike" — and watch who drifts out of sync, who stutters, and who falls into the spiral of death.
How to use this
All three dots should move at 240 px/s. 🔴 frame-tied (x += v per frame, calibrated for 60 FPS), 🟡 ×dt (x += v·dt), 🟢 fixed step + interpolation. Drop the render FPS to 15 — the red one moves four times slower. Raise the sim rate above the FPS and turn off interpolation — the green one stutters. Hit "frame spike" with clamp off — you get the spiral (dozens of steps per frame) and the yellow one teleports through the wall.
🔴 frame-tied
🟡 x += v·dt
🟢 fixed step + interp
accumulator
What to notice: 1) drop the FPS to 15 — 🔴 crawls at ~60 px/s (speed = FPS×step), 🟡 and 🟢 hold 240 (frame-independent). 2) sim = 10 Hz, FPS = 60, interpolation off — 🟢 stutters (it only updates 10 times/s); turn it on — smooth again. 3) clamp off + "spike": the steps per frame jump into the dozens (the spiral), and 🟡 hops through the wall (tunneling at a large dt). With clamp on, 🟢 goes into slow motion instead of spiraling.
🏠 What's next
Go back to the lesson, block "🔧 Run it and poke at it": put movement in Godot's _physics_process vs _process, turn off V-Sync — and you'll see exactly this on a real engine.
Connections
from the lesson
The game loop and fixed timestep — the theory: the accumulator,
n = ⌊a/dt⌋, interpolation α = a/dt, the spiral of death and the clamp.example
Doom — a fixed 35 ticks/second: the green strategy exactly, historically.
What to notice afterwards (observation checklist)
- At 15 FPS 🔴 slowed down while 🟡/🟢 held their speed — frame independence with your own eyes.
- sim < FPS without interpolation → 🟢 stutters; with interpolation → smooth.
- "Spike" without clamp → dozens of steps per frame (the spiral) and 🟡 teleports.
- "Spike" with clamp → 🟢 goes into slow motion, the accumulator never overflows.