🔢 2048

Slide, join, and keep doubling until you reach 2048

← Back to Fun Time
Score
0
Biggest
2
Moves
0
Best
0

⌨️ Controls

  • or W A S D slide everything
  • On a phone: swipe the board
  • SPACE keep playing after you reach 2048
  • P pause  •  R new game
  • 🎮 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

  • Every slide moves all the tiles as far as they can go.
  • Two tiles with the same number join into one worth double.
  • A new tile appears after every move that changed something.
  • A tile can only join once per move — four 2s become two 4s, not one 8.

🏆 Getting good

  • Pick a corner and keep your biggest tile there. Never move it out.
  • Use three directions and avoid the fourth — that keeps the big tile put.
  • Build a row in order along one edge: 2, 4, 8, 16…
  • The game is over only when there are no gaps and no equal neighbours.

🧑‍💻 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/twenty48-rules.js The rules: sliding, joining, turning slideRow, mergeRow, rotateBoard, moveBoard
lib/twenty48-draw.js Painting the tiles and their numbers tileLook, drawTile, renderGame
lib/twenty48-main.js The glue: the arrow keys and finger swipes doAction, connectSwipe, setUpGame

💡 The big idea: write one move, not four. Sliding left is the only direction this game really knows; the other three are done by turning the board round, sliding left, and turning it back. One function to get right, one place for a bug to hide.

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