This file provides guidance for AI assistants working with the firo_runner codebase.
firo_runner is an infinite runner game built with Flutter and the Flame game engine (v1.0.0-rc.11). A robot character navigates through progressively harder obstacles across 7 difficulty levels. The game supports Android, iOS, Web, Linux, and Windows, and includes an optional tournament mode with server connectivity for leaderboards.
# Install dependencies
flutter pub get
# Run in debug mode
flutter run
# Build for specific platforms
flutter build apk --bundle-sksl-path flutter_01.sksl.json --release
flutter build web --web-renderer canvaskit --release
flutter build linux
flutter build windows
flutter build ios
# Run tests
flutter test
# Run linter
flutter analyze
# Format code
dart format lib/lib/
├── main.dart # Entry point, MyGame class, server config constants
├── runner.dart # Player character with 30+ animation states
├── game_state.dart # Score, velocity, level progression, difficulty
├── firework.dart # Visual firework effects
├── holders/ # Object pool managers (spawn, update, render, cleanup)
│ ├── holder.dart # Base holder class
│ ├── platform_holder.dart
│ ├── coin_holder.dart
│ ├── bug_holder.dart
│ ├── wire_holder.dart
│ ├── debris_holder.dart
│ └── wall_holder.dart
├── moving_objects/ # Game entity classes extending MovingObject
│ ├── moving_object.dart # Base class: sprite, position, velocity, collision
│ ├── platform.dart
│ ├── coin.dart
│ ├── bug.dart
│ ├── wire.dart
│ ├── debris.dart
│ ├── wall.dart
│ └── circuit_background.dart
└── overlays/ # Flutter widget UI overlays
├── main_menu_overlay.dart
├── lose_menu_overlay.dart
├── leader_board_overlay.dart
├── sign_in_overlay.dart
└── deposit_overlay.dart
Other directories: assets/ (images, audio, fonts), android/, ios/, linux/, windows/, web/ (platform-specific build scaffolding), test/.
MyGame extends Flame's BaseGame with PanDetector, TapDetector, and KeyboardEvents mixins. It owns all game systems (holders, runner, state, background).
Each obstacle/collectible type has a Holder subclass that manages a pool of MovingObject instances. Holders handle spawning (level-based rates), updating, rendering, and off-screen cleanup. Each holder has 9 internal levels that map to game difficulty.
All entities (platforms, coins, bugs, wires, debris, walls) extend MovingObject. This base class handles sprite animation, positioning, velocity application, and collision detection via intersect() which returns direction strings ("top", "bottom", "left", "right").
Constants defined in main.dart:
OVERLAY_PRIORITY = 110,RUNNER_PRIORITY = 100,BUG_PRIORITY = 75COIN_PRIORITY = 70,PLATFORM_PRIORITY = 50,WALL_PRIORITY = 40DEBRIS_PRIORITY = 30,WIRE_PRIORITY = 25,FIREWORK_PRIORITY = 15
- Desktop/Web: Keyboard (WASD + arrow key alternatives)
- Mobile: Pan gestures and tap detection
- Unified through a
control(String)method accepting "up", "down", "left", "right", "center"
7 levels triggered by score thresholds (LEVEL2 through LEVEL7 constants in main.dart). Each level increases velocity (18%-30% of viewport width) and obstacle spawn rates. Robot upgrades unlock at coin milestones (50, 100+).
Controlled by constants in main.dart:
NO_TOURNAMENT— settruefor standalone/offline playSERVERandPORT— firo_runner_server endpoint for leaderboards- Uses
httppackage for API calls andshared_preferencesfor local caching
| Package | Purpose |
|---|---|
flame ^1.0.0-rc.11 |
2D game engine |
flame_audio ^1.0.0-rc.1 |
Game audio playback |
http ^0.13.3 |
HTTP client for tournament server |
qr_flutter ^4.0.0 |
QR code generation |
shared_preferences ^2.0.8 |
Local persistent storage |
cupertino_icons ^1.0.2 |
iOS-style icons |
Dart SDK: >=2.12.0 <3.0.0 (null safety enabled)
Uses flutter_lints (included via analysis_options.yaml). No custom rule overrides. Run flutter analyze to check for issues.
Test files live in test/. Currently minimal coverage (placeholder widget test). Run with flutter test.
- Constants: SCREAMING_SNAKE_CASE (e.g.,
LEVEL2,NO_TOURNAMENT,RUNNER_PRIORITY) - Animation states: Defined as enums per entity (e.g.,
RunnerState,PlatformState,BugState) - Sprite assets: Organized by entity under
assets/images/<entity>/with numbered frame files - Audio assets: Background music in
assets/audio/, sound effects inassets/audio/sfx/ - Font: Codystar (declared in
pubspec.yaml) - No CI/CD pipelines are configured — builds are done manually via Flutter CLI