Add 2048 game app#99
Open
jacola wants to merge 1 commit into
Open
Conversation
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.
Contributor
There was a problem hiding this comment.
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.pngso 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a 2048 sliding-tile puzzle game as a new badge app under
badge/apps/2048/.Controls
Per the badge's button layout:
Features
State.icon.png.Testing
badgewareruntime (py_compile+ 35+ assertions covering slide/merge rules,can_move, spawning, win detection, and the full press→slide→commit loop).Files
badge/apps/2048/__init__.py— game implementationbadge/apps/2048/icon.png— 24×24 launcher icon