📦 SOKOBAN

Push every crate onto a ring — you can push, but never pull

← Back to Fun Time
Level
1 / 6
Moves
0
Boxes home
0 / 1
Solved
0

⌨️ Controls

  • or W A S D walk
  • Tapping the board walks one step towards where you tapped
  • U, Z or BACKSPACE undo  •  R start the level again
  • N or ENTER next level  •  P pause
  • 🎮 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

  • Push every crate onto a ring. A crate standing on a ring is filled in solid.
  • You can only push. There is no way to pull a crate back.
  • Push a crate into a corner and it is stuck there for good — undo is your friend.
  • Six levels, getting harder. The last one needs sixteen moves.

🧠 Thinking ahead

  • Look at where each crate has to end up before you touch it.
  • A crate against a wall can only slide along that wall — never away from it.
  • Work out which side of a crate you need to stand on, and go there first.
  • Stuck? U as many times as you like. It costs nothing.

🧑‍💻 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/sokoban-rules.js The rules: the levels, the pushing, the undo isWall, boxAt, movePlayer, undoMove
lib/sokoban-draw.js Painting the walls, the crates and the player drawWall, drawBox, renderGame
lib/sokoban-main.js The glue: the keyboard, the taps, the buttons doAction, connectBoard, setUpGame

💡 The big idea: a stack gives you undo for free. Before every move, save a copy of everything and pile it up. Undo takes the top copy off and puts it back. That is how the undo button works in every program you have ever used.

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