One button. Gravity. And a great many pipes
← 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/flappy-rules.js | The rules: gravity, pipes, crashes | applyGravity, flap, movePipes, isCrashed |
| lib/flappy-draw.js | Painting the sky, the pipes and the bird | drawPipe, drawBird, renderGame |
| lib/flappy-main.js | The glue: the keyboard, the taps, the loop | doAction, connectBoard, gameLoop |
💡 The big idea: gravity changes speed, not position. Add a little to dy every frame, then move by dy. That one pattern is behind every jump, every falling rock and every bouncing ball you have ever played with.
🛠️ Want to be walked through it? Build Flappy Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.