How gghez/game-2048 works
2exp11 is an Android 2048-style puzzle: the player swipes a 4×4 board, the game engine slides and merges tiles, then the app spawns a tile and updates score, timer, and saved progress. The Compose screen is driven by a ViewModel, which also handles undo, settings, feedback, and optional leaderboard submissions. DataStore backs settings and game/score persistence; Google Play Games is an optional leaderboard integration. The workflow is grounded in the README and sampled sources; unsampled subsystem links are limited to documented capabilities and paths present in the tree.
Main entry points: GameViewModel.kt Game ViewModel · GameScreen.kt Game screen · Game2048App.kt App container · MainActivity.kt Main activity
Components 22
Android app
- Main activity
app/src/main/java/com/gghez/game2048/MainActivity.kt - App container
app/src/main/java/com/gghez/game2048/Game2048App.kt
Game interface
- Game screen
app/src/main/java/com/gghez/game2048/ui/game/GameScreen.kt - Game ViewModel
app/src/main/java/com/gghez/game2048/ui/game/GameViewModel.kt - Animated grid
app/src/main/java/com/gghez/game2048/ui/components/GameGrid.kt - Tile display
app/src/main/java/com/gghez/game2048/ui/components/TileView.kt - Score display
app/src/main/java/com/gghez/game2048/ui/components/ScoreCard.kt - New-game dialog
app/src/main/java/com/gghez/game2048/ui/components/NewGameDialog.kt - Settings sheet
app/src/main/java/com/gghez/game2048/ui/settings/SettingsBottomSheet.kt
Game domain
- Game engine
app/src/main/java/com/gghez/game2048/domain/GameEngine.kt - Board and tiles
app/src/main/java/com/gghez/game2048/domain/Board.kt - Game state
app/src/main/java/com/gghez/game2048/domain/GameState.kt - Random spawner
app/src/main/java/com/gghez/game2048/domain/RandomTileSpawner.kt
Persistence and scores
- Settings repository
app/src/main/java/com/gghez/game2048/data/settings/SettingsRepository.kt - Score and save repository
app/src/main/java/com/gghez/game2048/data/score/ScoreRepository.kt
Device integrations
- Leaderboard provider
app/src/main/java/com/gghez/game2048/data/leaderboard/LeaderboardProvider.kt - Game feedback
app/src/main/java/com/gghez/game2048/feedback/GameFeedback.kt - Tone synthesizer
app/src/main/java/com/gghez/game2048/feedback/Synth.kt
Other components
- Player
- Preferences DataStore
- Play Games
- Android audio and haptics
Connections 29
- Player → Main activity: opens and plays
- Main activity → Game screen: hosts
- Main activity → Settings sheet: opens
- Main activity → Leaderboard provider: attaches activity
- App container → Game ViewModel: provides dependencies
- Game screen → Game ViewModel: dispatches actions
- Game ViewModel → Game screen: publishes UI state
- Game screen → Animated grid: renders board
- Animated grid → Tile display: renders tiles
- Game screen → Score display: shows scores
- Game screen → New-game dialog: shows confirmation
- Settings sheet → Game ViewModel: dispatches changes
- Game ViewModel → Game engine: applies moves and starts games
- Game engine → Board and tiles: reads and updates
- Game engine → Game state: updates
- Game engine → Random spawner: chooses new tiles
- App container → Settings repository: constructs
- App container → Score and save repository: constructs
- App container → Leaderboard provider: constructs
- App container → Game feedback: constructs
- Game ViewModel → Settings repository: reads and updates settings
- Game ViewModel → Score and save repository: reads and saves progress
- Settings repository → Preferences DataStore: reads and writes
- Score and save repository → Preferences DataStore: reads and writes
- Game ViewModel → Leaderboard provider: submits scores
- Leaderboard provider → Play Games: signs in and submits
- Game ViewModel → Game feedback: signals moves and merges
- Game feedback → Tone synthesizer: renders tones
- Game feedback → Android audio and haptics: plays sound and vibrates