💡 LIGHTS OUT

Press a square and its neighbours flip — can you turn them all off?

← Back to Fun Time
Presses
0
Still lit
0
Best

⌨️ Controls

  • move the dashed cursor
  • Space or Enter press the square
  • Clicking or tapping a square works too
  • P pause  •  R new puzzle
  • 🎮 Xbox controller? Just plug it in or pair it — the stick and D-pad are the arrow keys, A is SPACE, Menu pauses and View starts again

🎯 How to play

  • Pressing a square flips it and its four neighbours — a plus shape.
  • At the edges the cross is smaller, because some neighbours do not exist.
  • Turn every light off to win.
  • Every puzzle can be solved — the game builds them by pressing, so they can always be un-pressed.

💡 Two tricks

  • Pressing the same square twice puts everything back. Every move is its own undo.
  • So the order you press in does not matter at all — only which squares you press.
  • That means every puzzle has a shortest answer, and no square ever needs pressing twice.
  • Try solving the top row first, then work down. It really helps.

🧑‍💻 For young coders: build this game yourself

This 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/lights-rules.js The rules: the cross, the flips, the win lightIndex, neighbours, pressLight, createPuzzle
lib/lights-draw.js Painting the lights and the cursor drawLight, squareAtPixel, renderGame
lib/lights-main.js The glue: clicks, keyboard, the scoreboard doAction, connectBoard, updateScoreboard

💡 The big idea: the puzzle is built by pressing random squares on a solved board. Because every press undoes itself, a puzzle made that way can always be solved — a lovely example of making a problem impossible to get wrong.

🛠️ Want to be walked through it? Build Lights Out Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.