Nine holes, one mole, forty-five seconds — 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/whack-rules.js | The rules: the mole, the clock, the scoring | randomHole, moleInterval, whack, updateGame |
| lib/whack-draw.js | Painting the holes and the mole | drawHole, drawMole, holeAtPixel |
| lib/whack-main.js | The glue: clicks, keyboard, the loop | doAction, connectBoard, gameLoop |
💡 The big idea: a timer is all that separates a board game from an arcade game. updateGame counts milliseconds and moves the mole when enough have passed — the same idea makes Tetris fall and the racing road scroll.
🛠️ Want to be walked through it? Build Whack-a-Mole Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.