Log inGet started
World

2048

Branchmain
Commitf7be24d6ad

README.md

Game2048

The complete 2048 sliding-tile merge puzzle in one self-contained world component: board state, the zui UI (HUD, board, menus, overlays), keyboard + WASD + swipe input, audio, and world-persistent progress. Pure board logic lives in the sibling logic2048 module; this component owns presentation, input, and persistence.

Attach it to a single entity (baked into scenes.main) and it mounts the whole game on scene materialize — it draws an opaque full-screen UI, so it needs no 3D scene content.

What it owns

  • State — N×N grid, score, best, move counter, win/keep-going/game-over flags, one-level undo, and lifetime stats (highest tile, wins, games played, total merges).
  • Loop — read a direction (arrows / WASD / swipe) → logic2048.move → on change: add score, spawn one tile, animate (merge-pop, spawn-fade), then test win (any 2048) and loss (full board, no moves).
  • UI — title + SCORE/BEST boxes, centered value-colored board, New Game / Undo, move counter, win + game-over overlays, Main / Settings / How-to-Play / Credits / Pause menus, and a first-run hint.
  • Persistence — best, board (resume via Continue), highest tile, win count, games played, total merges, and settings, via the game2048.* settings keys.

Methods (also used for validation)

  • :doMove(dir) — apply one move ("up"|"down"|"left"|"right").
  • :newGame() / :continueGame() / :undo().
  • :setBoard(grid, score?) — inject a board (testing).
  • :snapshot() — read { grid, score, best, moves, won, gameOver, ... }.