Nine lanes of traffic. One frog. Good luck
← 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/frogger-rules.js | The rules: the lanes, the traffic, the hops | laneSpeed, wrapCar, moveFrog, isSquashed |
| lib/frogger-draw.js | Painting the road, the cars and the frog | drawCar, drawFrog, renderGame |
| lib/frogger-main.js | The glue: the keyboard, the taps, the loop | doAction, connectBoard, gameLoop |
💡 The big idea: two different worlds can live in one game. The frog moves on a grid, one square at a time; the cars move in pixels, smoothly. Turning both into rectangles is what lets them meet.
🛠️ Want to be walked through it? Build Frogger Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.