Skip to content
Vuk Cvetković
GamesBuilt:

2048

Push the board in any direction and every tile slides as far as it can. Two of the same number merge into one worth double, and the aim is a single tile worth 2048.

Score0
Best0

Arrow keys or WASD, and a swipe on a phone.

How to play

  1. Push the whole board

    Arrow keys or WASD on a keyboard, a swipe in any direction on a phone. Every tile travels as far as it can in one move, not just one square.

  2. Equal numbers merge

    Two tiles carrying the same number become one worth double. A tile that has just merged is finished for that move, so a row of four 2s gives you two 4s rather than one 8.

  3. A new tile every move

    It arrives in a free cell and it is a 2 nine times out of ten. A push that changes nothing is not a move, so nothing new appears and nothing is lost by trying one.

  4. Pick a corner and stay there

    Keep the largest tile in one corner and never push away from it. Most of the game is refusing the move that lifts it out.

How it is built

No canvas and no game library. A tile is an element with two custom properties on it, its position is a translate resolved against its own size, and the browser composites the slide. That is where the smoothness comes from: a move changes a transform and nothing else, so no part of it goes through layout.

Keeping every tile’s element for the life of that tile is the other half. The board is never re-rendered from the state. A move updates the numbers on nodes that are already there, so a tile visibly travels from where it was instead of disappearing and reappearing somewhere else.

The numbers are text, so they are as sharp as the rest of the page and they scale with whatever size the reader has set. The colours are tokens in the same stylesheet as everything else, which is why the board answers the theme toggle in the header.

Input runs through one function from three places, so a key, a swipe and a mouse drag cannot drift into meaning slightly different things. The arrow keys belong to the board only while the board is on screen, and a move pushed before the last one has landed is held rather than dropped, so pushing quickly never costs you a turn.

Esc