Menu

1 / 4

Metronome Physics: Fixed Timestep Game Loops and Render Interpolation in TypeScript

JavaScript in Plain English - Medium·Mustafa Morbel·2 days ago
#tdsPuuDI
Reading 0:00
15s threshold

Member-only story

Game DevelopmentTypescriptCanvasPhysicsSimulation Metronome Physics: Fixed Timestep Game Loops and Render Interpolation in TypeScript

Mustafa Morbel

20 min read1 day ago

--

We upgrade our variable-dt loop into a fixed-timestep, deterministic physics engine — physics behaves identically across every machine while rendering stays silky-smooth at native display refresh rates.

Press enter or click to view image in full size

Last week, I launched the exact same game on two different computers. My desktop has a 144 Hz gaming monitor; my aging laptop struggles to hit 40 FPS on a good day. I launched the ball from the exact same coordinates at the exact same angle.

On the two machines, the ball landed in two completely different places.

In game development, this is a nightmare.

A physics simulation should never depend on the screen’s refresh rate. Whether a player sees 60 FPS, 30 FPS, or 144 FPS must not dictate where a projectile lands.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.