Polar Games

Slide. Merge. Reach 2048. · 1.0.0

2048 Robot Factory

An illustrated 2048 puzzle: swipe or use the keys to slide the tiles, merge equal pictures from the smallest tile to the biggest and reach the 2048 tile. HTML, CSS and JavaScript ES modules with no compile step, 14 interface languages and phone, tablet and desktop layouts. It runs with no account, server or database.

Version 1.0.0 Edition HTML5 static edition

This guide works without internet. Images, styles and scripts are already inside this file.

Contents
  1. Overview
  2. Install the ready-to-play game
  3. Requirements
  4. How to play and controls
  5. Interface
  6. Settings and language
  7. File map
  8. Customize and reskin
  9. Languages
  10. Saved progress
  11. Install Node.js and edit the source
  12. Updates and cache
  13. Troubleshooting
  14. Frequently asked questions
  15. Support and licenses
  16. For AI assistants

1 Overview

2048 Robot Factory is a sliding-tile puzzle on a 4 × 4 board. The player swipes or presses an arrow key and every tile slides as far as it can; when two tiles with the same number touch, they merge into one tile with double the value. After each move that changes the board, a new tile appears: a 2 (90% of the time) or a 4 (10%). Twelve illustrated tiles show the way from 2 to 4096, one picture for each value. A super tile is used for anything bigger.

Merging two 1024 tiles makes the 2048 tile and opens the victory screen, with two choices: Keep playing or New game. The run ends with "No moves left" when the board is full and no merge is possible. The mascot reacts to every move and travels along a progress trail that grows with the biggest tile.

This edition has no online ranking, account or in-app purchase. The board, the undo history, the best score, the settings and the language are saved in the player's browser only, so reloading the page continues the same game.

The download includes the ready-to-host game, the complete editable project (the same files, readable and commented, with tests and a local server), this guide, a separate step-by-step customization guide in English (CUSTOMIZATION.html) and the third-party license notice. The package contains:

START-HERE.txt
DOCUMENTATION.html
CUSTOMIZATION.html
CHANGELOG.txt
documentation/index.html
documentation/customization.html
game/
source/
THIRD-PARTY-LICENSES/

2 Install the ready-to-play game

Only the game/ folder needs to be uploaded to play.

  1. Extract the whole ZIP on your computer.
  2. Upload the contents of game/ to a folder on static hosting, using FTP or your host's file manager. Keep the folder structure exactly as it is.
  3. Open that folder's address in a modern browser. All paths are relative, so the game also works in a subfolder.
  4. Tap or click the first screen ("Tap to start") once: browsers only play audio after a user gesture. Test on the phones, tablets and computers you plan to support.
Warning Do not open index.html straight from the disk (a file:// address): browsers block ES modules and sounds there. Use a web host, or the local server described in "Install Node.js and edit the source".

3 Requirements

  • Any static web host able to serve plain files over HTTP or HTTPS (HTTPS recommended).
  • A current desktop or mobile browser with JavaScript enabled.
  • Node.js 26.13.0 or newer (current LTS line), only if you want to run the tests, the local server or the build command.

No database, PHP, backend, account or internet service is needed. The game, the font, the art and the sounds are all inside game/.

4 How to play and controls

Slide all the tiles in one direction. Tiles with the same number that touch merge into one with double the value. Keep merging until the 2048 tile appears.

  • Touch screens: swipe anywhere on the screen except over buttons and windows. The move starts as soon as the finger has moved a short distance, and a quick flick is also accepted.
  • Keyboard: the arrow keys or W, A, S, D move all the tiles.
  • Undo: the Undo button, or the Z, U or Backspace key, or Ctrl+Z (Cmd+Z on macOS).
  • R restarts the game (while a game is in progress it first opens the Pause window, so a game is never lost by accident), M mutes or restores all sound, and Esc opens Pause or closes the open window.

Score: every merge adds the value of the new tile (merging two 16 tiles adds 32). A move that changes nothing does not count: the tiles only nudge and the mascot looks grumpy.

Undo takes back the last move, up to 20 moves in a row. The undo history is saved with the game. After "No moves left" the Undo move button gives the last move back.

Winning: when the 2048 tile appears, the victory screen opens. Keep playing continues on the same board with no limit, and New game starts again. Tiles above 4096 use the super tile picture.

Milestones: the first time a 128, 256, 512, 1024, 4096, 8192 or 16384 tile is made, a banner with its name appears. The 2048 milestone opens the win screen instead of a banner.

Progress trail: the mascot's head moves toward the goal tile as the biggest tile grows. It starts at 4000 and reaches 0 at 2048. In the portrait layout the distance left is written next to the trail (for example 400).

Combo: when consecutive moves each merge something, a Combo ×2 or higher badge appears and the sounds climb the scale. A combo of 3 makes the mascot cheer; when 2 or fewer cells are empty it looks worried.

5 Interface

Real captures of the shipped build at 1280 x 720 and on a phone, with numbered marks for the elements described in this guide.

First screen: Tap to start
First screen: Tap to start

Marks on the screenshot

  1. Tap to start: the first tap or key press unlocks the audio and brings in the menu
  2. Game logo
  3. The mascot
Main menu (landscape)
Main menu (landscape)

Marks on the screenshot

  1. Play starts a game; it reads Continue when a game is in progress
  2. Best score
  3. Sound: opens the Music and Effects volumes
  4. Settings
A game in progress
A game in progress

Marks on the screenshot

  1. Pause
  2. Current score
  3. Best score
  4. Progress trail: the mascot moves up toward the goal tile
  5. The 4 × 4 board, with its frame
  6. Undo
  7. The mascot, which reacts to the moves
  8. Sound
  9. Settings
Sound window
Sound window

Marks on the screenshot

  1. Music volume
  2. Effects volume
  3. Close: returns to where you were
Settings window
Settings window

Marks on the screenshot

  1. Vibration (only on devices that support it)
  2. Less motion: calmer effects
  3. Language: opens the list of 14 languages
  4. Close
Language window (14 languages)
Language window (14 languages)

Marks on the screenshot

  1. The language in use is highlighted
  2. Tap any other language: the whole interface changes at once
  3. Close
Pause window
Pause window

Marks on the screenshot

  1. Continue: back to the game
  2. Restart: starts a new game
  3. Settings: returns here when closed
  4. Menu: back to the main menu
Victory screen
Victory screen

Marks on the screenshot

  1. Title of the win screen
  2. Keep playing: continues on the same board
  3. New game: starts again
  4. Score of this game
  5. The 2048 tile that was made
  6. Home: back to the main menu
"No moves left": the end of a game
"No moves left": the end of a game

Marks on the screenshot

  1. Final score
  2. Best tile of this game
  3. Play again starts a new game at once
  4. Undo move: takes back the last move and keeps playing
  5. Home: back to the main menu
The main menu on a phone (portrait)
The main menu on a phone (portrait)

Marks on the screenshot

  1. Play or Continue
  2. Best score
  3. Sound
  4. Settings
The portrait phone layout during a game
The portrait phone layout during a game

Marks on the screenshot

  1. Pause
  2. Current score
  3. Best score
  4. Progress trail, from Start to the goal tile
  5. Distance left to the goal tile
  6. The board: swipe anywhere on the screen
  7. Undo

6 Settings and language

The Sound button opens a window with the Music and Effects volumes, and the Settings button opens Vibration (shown only on touch devices that support it), Less motion and Language. Less motion starts switched on when the device asks for reduced motion. Both windows open from the menu and during a game. Every choice is saved in the browser.

On the first visit the game uses the browser language when it is one of the 14 supported, otherwise English. A language picked by the player is remembered. For testing you can also add ?lang=pt (or another code) to the address.

7 File map

game/ and source/ contain the same game files: game/ is what you upload, and source/ is the project you edit, with tests and tools. Run npm run build in source/ to copy your changes into source/dist/, which is identical to game/.

Path What it is
game/ The ready-to-host game. Upload its contents.
source/index.html Entry page: every screen and window of the game (menu, game, win, game over, pause, sound, settings, language).
source/css/ Styles of every screen. 06-layout.css holds the position and size of every piece, in portrait and landscape.
source/src/config.js The rules, the timing, the FEEL effects block, the tile colors, the audio levels and the save keys, all in one commented file.
source/src/game/rules.js The 2048 logic: moves, merges, score, win, game over, undo and saving. No drawing and no sound.
source/src/app/ Game flow: moves, screens, settings and saved state.
source/src/input.js Keyboard and swipe controls.
source/src/render/ Drawing: the board, tile animation, particles and the background.
source/src/ui/ Interface: the score and trail, the windows, text fitting and nine.js, the stretchable panel art.
source/src/audio/ Audio: the music loop, the recorded sounds and the synthesized fallback.
source/src/lib/locales/ Interface texts, one file per language.
source/assets/ Tile pictures (t-2.webp to t-4096.webp and t-super.webp), the mascot, buttons and panels, icons, backgrounds, particles, music and sounds, the logo, the board frame and the victory picture.
source/fonts/ The Fredoka font and its license.
source/test/ Tests run by npm test: the 2048 rules and the 14 language files.
source/tools/ The local server, the build and the Node.js version check.

Internal names

Some names in the code differ from what the player sees. They are kept stable so saves stay compatible. Rename them only if you also update every use.

In the code In the game
blip The mascot and its expressions (assets/blip/)
depth, g-tube, g-blip, g-end The progress trail beside the board: the distance left to the 2048 tile
--u The layout unit: 1u is 1% of the design frame, so the layout scales with the screen
html body:not(#z) A selector that raises a rule's priority so the layout file wins without !important
nine Panel and button art cut in 9 pieces, so it stretches without deforming its corners
golden The picture on the victory screen (assets/golden.webp)

8 Customize and reskin

Everything can be changed in source/ with any text editor. Work on a copy, change one thing at a time, test with npm run dev, then run npm run build and upload the new dist/.

Tip Step-by-step recipes for people who do not program (replace a tile picture, the mascot, a text, a sound, colors, rules, publish) are in CUSTOMIZATION.html, in the root of the download (in English).
  • Tile pictures: replace source/assets/tiles/t-2.webp to t-4096.webp and t-super.webp keeping the names and the size (about 256 × 248 pixels). The number is drawn by the game, so do not paint it. The glow color of each tile is tiles in source/src/config.js.
  • The mascot: source/assets/blip/ has six expressions (idle, joy, wow, grumpy, worry, think) and cabeca.webp, the small head that moves along the progress trail.
  • Backgrounds, logo and frame: source/assets/bg/, logo.webp, frame.webp and golden.webp in source/assets/. If the frame art changes, adjust board in config.js.
  • Buttons and panels: source/assets/ui/ (9-slice art: keep the frame shape) and the CSS files in source/css/.
  • Texts: source/src/lib/locales/, one file per language. Keep the v and s (between curly braces) markers.
  • Sounds and music: replace the MP3 files in source/assets/audio/ keeping the names. For another music track, set loopStart and loopEnd (in seconds) in config.js.
  • Rules and effects: gridSize, spawnFourChance, maxUndo, winValue and milestones in CONFIG, and the FEEL block, in config.js. To move or resize a piece, edit its numbers in source/css/06-layout.css.
// source/src/config.js (excerpt)
export const CONFIG = {
  gridSize: 4,
  spawnFourChance: 0.1,
  maxUndo: 20,
  winValue: 2048,
  milestones: [128, 256, 512, 1024, 2048, 4096, 8192, 16384],
  // ...
};
Tip After changing numbers, run npm test and play a few games: the tests check the 2048 rules and that every language has the same texts.

9 Languages

The interface ships in 14 languages: English, Portuguese, Spanish, French, German, Italian, Dutch, Polish, Turkish, Russian, Indonesian, Japanese, Korean and Chinese (Simplified).

Each language is a file in source/src/lib/locales/ with the same keys as en.js; a key missing in a language falls back to English. The list of languages is in source/src/lib/locales/index.js. npm test checks that every language has the same keys as English.

10 Saved progress

The current board, the undo history, the best score, the settings and the language are saved automatically in the browser's local storage, under keys that start with 2048-robot-factory.template.save.v1. Nothing is sent anywhere.

  • Clearing the site data for the game's address deletes this save.
  • There is no cloud save or account: progress stays in that browser on that device.
  • To host two copies of the game on the same domain, change the prefix in source/src/config.js (storageKeys) and in source/src/lib/i18n.js in one of them.

11 Install Node.js and edit the source

Node.js is only needed for the optional tools: the tests, the local server and the build command. The game itself is plain files and needs nothing installed.

  1. Download the LTS version of Node.js (26.13.0 or newer) from nodejs.org and install it with the default options (Windows and macOS installers; on Linux use the package from nodejs.org or your distribution).
  2. Open a new terminal (Windows: PowerShell or Command Prompt; macOS: Terminal) and check the versions with the first two commands below.
  3. Go to the extracted source/ folder, for example cd Downloads/2048-robot-factory-static-1.0.0/source.
  4. Run npm ci. The project has no npm dependencies, so this only checks package-lock.json, but it keeps the usual workflow.
  5. Run npm test for the tests, and npm run dev to play the source at http://localhost:5190/ (stop it with Ctrl+C).
  6. Run npm run build. It deletes and writes source/dist/ again; upload the contents of dist/ to your host.
node --version
npm --version
npm ci
npm test
npm run dev
npm run build

Common problems:

  • "node" or "npm" is not recognized: Node.js is not in the PATH yet. Close the terminal and open a new one, or reinstall Node.js.
  • Windows PowerShell says running scripts is disabled for npm.ps1: use Command Prompt, or type npm.cmd ci, npm.cmd test and so on.
  • ENOENT or "Could not read package.json": the terminal is not inside the source/ folder.
  • EBADENGINE or "needs Node.js 26.13.0 or newer": install the current LTS version of Node.js.

Port 5190 is busy: choose another port first (PowerShell: $env:PORT=8090; macOS and Linux: PORT=8090 npm run dev).

12 Updates and cache

To publish a new version, upload the full contents of the new game/ (or dist/) over the old files, overwriting them. Saved progress is kept.

If players still see the old version after an update, it is almost always the browser or host cache, not a failed upload.

Clearing the cache without losing progress

Progress is stored in this browser, not on the server. Clearing cached images and files, or doing a hard reload, keeps your progress.

Computer: press Ctrl+F5 on Windows and Linux, or Cmd+Shift+R on macOS. Phone: in the browser settings, choose the option to clear cached images and files.

Do not choose cookies and site data, or clear site data, for the game's address. That deletes the local save.

13 Troubleshooting

  • Blank page: open the browser console (F12) and look for a file that failed to load; confirm every file of game/ was uploaded, including src/, css/, fonts/ and assets/.
  • It works on your host but not from the disk: browsers block ES modules on file:// addresses. Use a web address or npm run dev.
  • No sound: audio starts after the first tap, click or key press, by browser rule. Check that Music and Effects in the Sound window are not at 0 and that sound is not muted (M key).
  • The game opens in the middle of a game: that is the saved game. Use Restart in the Pause window, or clear the site data of the address, to start from zero.

14 Frequently asked questions

Do I need to build the game?
No. Upload the contents of game/ to any static host. source/ is only for editing, testing and rebuilding.
Does the game need a server or database?
No. It is static files; progress is saved in the player's browser.
Can I change the pictures and the theme?
Yes. Replace the art in source/assets/, the sounds in source/assets/audio/, the texts in the language files and the numbers in source/src/config.js, then run npm run build.
Does it work without internet?
Once uploaded, the game makes no requests outside its own folder: there is no CDN, analytics or external service. It needs a web address only because browsers require one for ES modules.
Can I resell this template as-is?
Check the license terms of the item page where you bought it before reselling, redistributing or reusing it in another product.

15 Support and licenses

The game uses the Fredoka font (SIL Open Font License 1.1). Its notice is in THIRD-PARTY-LICENSES/ and game/fonts/OFL.txt; keep it with your product.

For product support or custom development, write to the address below.

Support request

When you write to support, include the browser and device, the game version, the page address, the steps that caused the problem, a screenshot and the first error shown in the browser console. Never send passwords, payment details or secret keys.

For AI assistants

  • Read the File map and Customize sections first. Upload only game/ (or source/dist/); source/ is the editable project.
  • Keep the save prefix, the relative paths, the internal names listed in the File map and the v and s (between curly braces) markers unless the buyer asks for a change. Run npm test after every change.
  • Do not assume an account, a server, payments or an online ranking: this edition has none, and the code is the source of truth.