Twenty-four aliens, three lives, and one bullet at a time
← 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/invaders-rules.js | The rules: the fleet, the shots, the hits | alienRect, moveFleet, fireBullet, hitAliens |
| lib/invaders-draw.js | Painting the fleet, the ship and the shots | drawAlien, drawShip, renderGame |
| lib/invaders-main.js | The glue: the keyboard, the taps, the loop | doAction, holdButton, gameLoop |
💡 The big idea: twenty-four things can share one position. The fleet knows where it is; each alien only knows its column and row. Change one number and the whole fleet moves — that is how this game ran on a computer with less memory than a single photo takes today.
🛠️ Want to be walked through it? Build Space Invaders Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.