Skip to content

Add 2048 game app#99

Open
jacola wants to merge 1 commit into
badger:mainfrom
jacola:jacola-2048-game
Open

Add 2048 game app#99
jacola wants to merge 1 commit into
badger:mainfrom
jacola:jacola-2048-game

Conversation

@jacola

@jacola jacola commented Jun 25, 2026

Copy link
Copy Markdown

What

Adds a 2048 sliding-tile puzzle game as a new badge app under badge/apps/2048/.

Controls

Per the badge's button layout:

  • A → slide left
  • B → slide right
  • UP → slide up
  • DOWN → slide down
  • HOME → back to launcher (handled by the system)

Features

  • Full 2048 mechanics: tile merging, random 2/4 spawns, win at the 2048 tile (keep playing after), and game-over detection when no moves remain.
  • Smooth slide, spawn-pop, and merge-pulse animations.
  • Classic 2048 palette with a score + best-score panel.
  • Board, score, best, and win state persisted between sessions via State.
  • Auto-discovered by the launcher menu with a 24×24 icon.png.

Testing

  • Validated the game logic offline against a mocked badgeware runtime (py_compile + 35+ assertions covering slide/merge rules, can_move, spawning, win detection, and the full press→slide→commit loop).
  • Ran the app in the actual Pygame badge simulator and captured screenshots of every state: title, gameplay, slide animation, the 2048 win toast, and game over — all render correctly.

Files

  • badge/apps/2048/__init__.py — game implementation
  • badge/apps/2048/icon.png — 24×24 launcher icon

Add a 2048 sliding-tile puzzle under badge/apps/2048 with A/B for
left/right and UP/DOWN for vertical moves. Includes tile merge
logic, score and best-score persistence via State, win and
game-over states, slide/spawn/merge animations, and a 24x24
launcher icon.
Copilot AI review requested due to automatic review settings June 25, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new 2048 sliding-tile puzzle app to the Universe 2025 Tufty badge app collection (badge/apps/), including UI, animations, and persistent state via State.

Changes:

  • Introduces a complete 2048 implementation (slide/merge/spawn, scoring, win + gameover detection) with slide/spawn/merge animations.
  • Persists board/score/best/win state between sessions using State.
  • Adds a 24×24 icon.png so the app is auto-discovered and displayed in the launcher.
Show a summary per file
File Description
badge/apps/2048/init.py Implements the 2048 game loop, move logic, rendering, animations, and persisted state.
badge/apps/2048/icon.png Launcher icon for the new 2048 app.

Copilot's findings

  • Files reviewed: 1/2 changed files
  • Comments generated: 1

Comment on lines +101 to +106
b = saved.get("board", [0] * 16)
if isinstance(b, list) and len(b) == 16:
board = [int(v) for v in b]
score = int(saved.get("score", 0))
best = int(saved.get("best", 0))
won = bool(saved.get("won", False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants