Wait for the black, then press. How fast are you really?
← Back to Fun TimeThis game is split into small library files inside funtime/lib/, and every function has a comment saying exactly what goes in, what comes out, and the algorithm in plain English. Empty any function out, read its comment, and write it yourself.
| File | What it does | Good functions to try re-writing |
|---|---|---|
| lib/reaction-rules.js | The rules: the phases, the delay, the stopwatch | randomDelay, updateGame, press, averageTime |
| lib/reaction-draw.js | Painting the signal panel and the bar chart | panelWords, drawPanel, drawHistory |
| lib/reaction-main.js | The glue: the keyboard and the panel | doAction, connectBoard, gameLoop |
💡 The big idea: a phase. This game is always in exactly one of five states, and every single rule starts by asking which one. One button means five different things — and the code stays simple because each branch only has to worry about its own case.
🛠️ Want to be walked through it? Build Reaction Test Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.