A scripted test ride
The real physics.js of the build, inlined, with a stand-in bike. Fixed step counts, so the numbers are the same every run.
A small game is a loop of input, physics and camera: held keys or buttons set forces, the world steps at a fixed rate, the camera follows, and a watchdog resets the bike when it falls over. Script the input with fixed steps and the whole ride becomes testable.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 4 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Add a boost key (B) that doubles the pedal force while held.
Make the watchdog reset a fallen bike after half a second instead of one.
Explain it without notes
Walk through one frame of the test ride: from a held key to a moved camera.
Why does the ride use forces and damping instead of setting the bike's velocity directly?
Console
Nothing logged yet.Expected console output
settled on the track x -0.00 | speed 0.00 m/s | y -0.00 | tilt -0.0°
2 s pedalling x 2.46 | speed 2.23 m/s | y -0.00 | tilt -0.0°
1 s braking x 3.04 | speed 0.05 m/s | y -0.00 | tilt -0.0°
8 s more pedalling x 25.28 | speed 4.31 m/s | y -0.00 | tilt -0.0°
highest point over the ramp: 0.12 m | the camera followed: 25.28 m