← All interactive demos

Slowdown and Time — Interactive Demo

This is the working model from the video "Why Do Old Games Slow Down with More Enemies?". The machine in this model can only do "20 enemies' worth" of work per frame (1/60 s) (one enemy = drawing 0.8 + moving 0.2). Until the work is done, the screen keeps showing the previous picture. You can switch between 3 ways of moving time forward in the game.
A Count frames: each loop moves 1/60 s forward. B Measure with a clock: move forward by the time passed since the last loop. C Save up, fixed steps: save up the time passed, move forward several times in 1/60 s steps, then draw (with a cap on how many steps per loop).

1. Play and change

 
← → to move, ↑ to jump, Space to shoot (on a phone, use the buttons above).
Task: stay on method C, set the "step cap" to 1 frame, and add enemies. From how many enemies does it slow down? Does the jump height change then?
Answer and reasoning(With 60 screen draws per second and machine power 20) it starts at 21 enemies. With a cap of 1, each screen can only move 1 frame forward, so the work per loop is "drawing 0.8 + moving 0.2" × enemies = the number of enemies. Above 20 it no longer fits in 1 frame and slows down just like method A. The jump height stays at 3.87 squares (the step is always 1/60 s). Set the cap back to 8 and it keeps normal speed up to 66 enemies and slows from 67 (at 100 enemies, moving alone uses up all the machine power).

2. Compare the 3 methods with the same input recording

An input recording that runs right, jumps to a platform 3.6 squares high and shoots at a wall (1 square thick) is calculated with A, B and C, using the "enemies, screen draws, machine power, step cap" set above.

Clock speedAt 3 sPeakPlatformBullet

Positions and heights are in squares. The video's settings are "50 enemies, 30 draws/s, machine power 20, cap 8" (A runs at 1/4 speed, B reaches only 3.48 squares and the bullet passes through, C reaches 3.87 squares).

3. Make your own: sample code

A single HTML file with one square and one wall where you can try all 3 methods. Download sample.html and just open it in a browser (open it here). Change MODE to 'A', 'B' or 'C', and use the "weight" slider to slow down each loop on purpose. (The comments in the code are in Japanese.)

Loading…

This page uses the same calculation as the video's diagrams (sim.js). These are not real game values. Slowdown in real games depends on how they are built and what they process, not just the number of enemies. "Screen draws" is calculated inside this model and is separate from your display's actual refresh rate (60 Hz, 120 Hz, etc.) (120 per second is calculation only; the display skips some).
Sources and credits: same as the video description (AI was used to make the diagrams and script; no game footage or characters are used).