How gtxprime/arrow-escape works
Purpose and Entry Points
Arrow Escape is a Flutter/Flame casual puzzle game: tap arrows to slide them from a grid, clearing each deterministic level. Runtime starts at lib/main.dart, builds the app shell in lib/app.dart, and uses the Android Flutter host at android/app/src/main/kotlin/com/arrowx/escape/MainActivity.kt.
App Navigation and Presentation
Flutter screens provide the non-game flow: splash, menu, level selection, settings, game, and game-over. The game screen bridges Flutter UI and the Flame game runtime.
• lib/screens/splash/splash_screen.dart
• lib/screens/game/game_screen.dart
• lib/screens/level_select/level_select_screen.dart
Gameplay Runtime
ArrowPuzzleGame is the Flame orchestration layer, maintaining mutable game state, input/animation lifecycle, grid rendering, individual arrows, and visual effects. It operates on decoded level models rather than generating UI-specific board data.
• lib/game/arrow_puzzle_game.dart
• lib/game/game_state.dart
• lib/game/components/grid_component.dart
• lib/game/components/arrow_component.dart
Level Content Pipeline
The shipped source of truth for playable content is the pre-generated binary asset, enabling O(1)-style indexed level retrieval without generation during normal play. LevelRepository loads/delegates level access; LevelBinaryCodec defines the serialization boundary between build-time level generation and runtime gameplay.
• assets/levels.bin
• lib/data/repositories/level_repository.dart
• lib/data/level_binary_codec.dart
• lib/data/models/level.dart
Deterministic Generation and Validation
Build-time generation derives a reproducible puzzle from level number, constructs masks and arrow arrangements in reverse, adds deflectors/color pairing, then verifies solvability with greedy simulation and DFS before binary packaging. V2 is the architecture-defining generator; scripts support regeneration/verification of the asset.
• lib/data/level_generator/level_generator_v2.dart
• lib/data/level_generator/mask_generator_v2.dart
• lib/data/level_generator/solver.dart
• bin/pregenerate_levels.dart
Player State, Audio, and Assets
Progress (unlocked levels, lives/stars or related persistence) is isolated behind a repository backed by Shared Preferences. Audio is centrally managed and served from packaged assets; game art, fonts, audio, and level data remain local—no gameplay backend is indicated.
• lib/data/repositories/progress_repository.dart
• lib/data/models/player_progress.dart
• lib/core/audio_manager.dart
• assets/audio/
Monetization and Platform Boundaries
Ads are an optional, centrally controlled service integration with an AdMob-first and Unity fallback policy. Flutter targets Android, iOS, web, and Windows; this tree includes only the Android native project. Android manifest/build settings form the native boundary for ad SDK registration and packaging.
• lib/ads/ad_manager.dart
• lib/widgets/unified_banner_ad.dart
• lib/core/constants.dart
• android/app/src/main/AndroidManifest.xml
Main entry points: arrow_puzzle_game.dart Arrow puzzle game · level_binary_codec.dart Binary codec · pregenerate_levels.dart Level packaging · app.dart App shell
Components 25
Flutter app
- Runtime entry
lib/main.dart - App shell
lib/app.dart - Splash screen
lib/screens/splash/splash_screen.dart - Level selection
lib/screens/level_select/level_select_screen.dart - Game screen · Hosts the Flame runtime within Flutter navigation.
lib/screens/game/game_screen.dart - Banner ad widget
lib/widgets/unified_banner_ad.dart
Gameplay runtime
- Arrow puzzle game · Owns game lifecycle, input, animation, and rendering.
lib/game/arrow_puzzle_game.dart - Game state
lib/game/game_state.dart - Grid renderer
lib/game/components/grid_component.dart - Arrow entities
lib/game/components/arrow_component.dart
Level content
- Level repository
lib/data/repositories/level_repository.dart - Binary codec
lib/data/level_binary_codec.dart - Shipped levels · Pre-generated indexed playable content.
assets/levels.bin - Level model
lib/data/models/level.dart - Level packaging · Regenerates and verifies the shipped binary asset.
bin/pregenerate_levels.dart - V2 generator · Builds reverse puzzle layouts from a level number.
lib/data/level_generator/level_generator_v2.dart - Mask generator
lib/data/level_generator/mask_generator_v2.dart - Solvability solver · Uses greedy simulation and DFS validation.
lib/data/level_generator/solver.dart
Platform services
- Android host
android/app/src/main/kotlin/com/arrowx/escape/MainActivity.kt - Progress repository · Persists unlocks and player progression via Shared Preferences.
lib/data/repositories/progress_repository.dart - Player progress
lib/data/models/player_progress.dart - Audio manager
lib/core/audio_manager.dart - Audio assets
- Ad manager · Uses AdMob first with Unity fallback.
lib/ads/ad_manager.dart - Android manifest · Registers ad SDK and Android packaging boundary.
android/app/src/main/AndroidManifest.xml
Connections 25
- Android host → Runtime entry: launches Flutter
- Runtime entry → App shell: builds
- App shell → Splash screen: starts navigation
- App shell → Level selection: navigates
- Level selection → Progress repository: reads unlocks
- Level selection → Game screen: opens level
- Game screen → Arrow puzzle game: hosts
- Arrow puzzle game → Game state: maintains
- Arrow puzzle game → Grid renderer: renders
- Arrow puzzle game → Arrow entities: controls
- Arrow puzzle game → Level repository: loads level
- Level repository → Binary codec: decodes with
- Binary codec → Shipped levels: reads
- Binary codec → Level model: produces
- Arrow puzzle game → Progress repository: updates progress
- Progress repository → Player progress: persists
- Arrow puzzle game → Audio manager: plays effects
- Audio manager → Audio assets: loads
- Banner ad widget → Ad manager: requests ad
- Ad manager → Android manifest: requires SDK registration
- Level packaging → V2 generator: generates levels
- V2 generator → Mask generator: constructs masks
- V2 generator → Solvability solver: validates output
- Level packaging → Binary codec: packages with
- Level packaging → Shipped levels: writes