Bounce the ball, clear the wall — and never let it past you
← 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/breakout-rules.js | The rules: the ball, the bounces, the bricks | hitsRect, bounceOffWalls, bounceOffPaddle, breakBricks |
| lib/breakout-draw.js | Painting the wall, the bat and the ball | drawBrick, drawPaddle, renderGame |
| lib/breakout-main.js | The glue: the keyboard, the mouse, the loop | doAction, connectMouse, gameLoop |
💡 The big idea: a bounce is just a flipped direction. dy = -dy and the ball goes back the way it came. Almost all game physics is made of tiny rules like that, run sixty times a second.
🛠️ Want to be walked through it? Build Breakout Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.