An arcade-style Flutter + Flame game where you guide an otter down river rapids while collecting items and dodging hazards.
- 🎮 Smooth Gameplay - Fast-paced river navigation with responsive tap controls
- 🎯 Score System - Collect lilies and avoid logs to build your high score
- ❤️ Health Management - Start with 3 hearts, collect power-ups to restore health
- 📈 Progressive Difficulty - River speed increases over time for added challenge
- 🏆 Leaderboards - Compete globally with authenticated players
- 👤 Player Profiles - Track achievements, game history, and statistics
- 🔐 Secure Authentication - JWT-based auth with certificate pinning support
- 🎵 Immersive Audio - Background music and sound effects
- 🎨 Beautiful Graphics - Animated sprites and smooth visuals
- 🔄 Guest Mode - Play without an account (scores won't sync)
Stay alive as long as possible while racking up the highest score!
- Tap anywhere on the screen to move the otter horizontally toward the tap position
-
🪵 Logs (60% spawn rate)
- Avoid these! Colliding with a log costs one heart
- Repeated collisions end your run
-
🌸 Lilies (25% spawn rate)
- Collect these for 10 points each
- Focus on gathering as many as possible for a high score
-
❤️ Hearts (15% spawn rate)
- Restore one heart when collected (max 3 hearts)
- Essential for survival on longer runs
- Starting Speed: 120 px/s
- Speed Increase: ~10% every 20 seconds
- Maximum Speed: 240 px/s (capped)
When you run out of hearts, you'll see:
- Final score
- Statistics (lilies collected, hearts collected)
- Option to submit score (if authenticated)
- Play Again or return to Main Menu
- Flutter 3.38+ (check with
flutter --version) - Dart SDK 3.10+ (bundled with Flutter)
- Backend API - Rails API server running (see Backend Repository)
-
Clone the repository
git clone <repository-url> cd otter_drift
-
Install dependencies
flutter pub get
-
Configure API credentials
Run the app with required environment variables:
flutter run \ --dart-define=API_KEY=your_64_char_hex_key \ --dart-define=CLIENT_ID=game_client_1 \ --dart-define=API_BASE=http://localhost:3000
Note: Android emulators automatically use
http://10.0.2.2:3000instead oflocalhost -
Build for release
flutter build apk --dart-define=API_KEY=prod_key_here # or for iOS flutter build ios --dart-define=API_KEY=prod_key_here
otter_drift/
├── lib/
│ ├── game/ # Flame game engine code
│ │ ├── components/ # Game entities (Otter, Logs, Lilies, Hearts)
│ │ ├── hud/ # Heads-up display components
│ │ └── otter_game.dart # Main game class
│ ├── screens/ # Flutter UI screens
│ │ ├── auth/ # Login/Signup screens
│ │ ├── game/ # Game screen wrapper
│ │ ├── menu/ # Main menu screen
│ │ └── profile/ # Profile management screens
│ ├── services/ # Business logic & API integration
│ │ ├── api_service.dart # HTTP client wrapper
│ │ ├── auth_service.dart # Authentication handling
│ │ ├── backend.dart # API endpoint definitions
│ │ └── security_config.dart # Certificate pinning config
│ ├── models/ # Data models
│ ├── widgets/ # Reusable UI widgets
│ └── util/ # Utilities (RNG, etc.)
├── assets/ # Game assets
│ ├── images/ # Sprites and UI graphics
│ └── audio/ # Sound effects and music
├── test/ # Test suite
│ ├── game/ # Game logic tests
│ ├── screens/ # Widget tests
│ └── util/ # Utility tests
└── pubspec.yaml # Dependencies and asset configuration
Run the test suite:
# Run all tests
flutter test
# Run specific test file
flutter test test/util/rng_test.dart
# Run with coverage
flutter test --coverageCurrently passing: 11 tests (RNG utility tests)
| Variable | Description | Default |
|---|---|---|
API_KEY |
64-character hex API key for backend authentication | Required |
CLIENT_ID |
Client identifier for the API | game_client_1 |
API_BASE |
Base URL for the backend API | http://localhost:3000 |
- JWT Tokens: Stored securely via
flutter_secure_storage - Certificate Pinning: Configurable in
lib/services/security_config.dart - Sensitive Logging:
SecureLoggerautomatically masks sensitive fields
This project requires a Rails API backend. See the backend repository for setup instructions.
The backend must provide:
- Authentication endpoints (login, signup, refresh)
- User profile management
- Leaderboard API
- Game session submission endpoint
Default API routes:
/api/v1/auth/*- Authentication/api/v1/players/*- Player data/api/v1/leaderboard- Global leaderboard/api/v1/game_sessions- Score submission
Missing API Key Error
Error: API_KEY is required
Solution: Run with --dart-define=API_KEY=your_key_here
401 Authentication Errors
- Verify backend is running
- Check API key matches backend configuration
- Ensure device/emulator can reach the API URL
- Android emulator should use
http://10.0.2.2:3000instead oflocalhost
Assets Not Loading
- Run
flutter pub getafter modifyingpubspec.yaml - Verify asset paths in
pubspec.yamlmatch file structure - For web builds, check asset bundling configuration
Audio Issues
- Ensure audio files are in
assets/audio/directory - Check file formats are supported (WAV recommended)
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Flutter - UI framework
- Flame 1.33 - Game engine
- Flame Audio - Audio system
- Dio - HTTP client
- Connectivity Plus - Network status
- Flutter Secure Storage - Secure credential storage
- Shared Preferences - App preferences
- JWT Decoder - Token parsing
- Google Mobile Ads - AdMob integration for banner, interstitial, and rewarded ads
See pubspec.yaml for complete dependency list.
Generate API documentation using dartdoc:
dart docDocumentation will be generated in docs/api/.
For instructions on deploying to Google Play Store and configuring advertisements, see the Deployment Guide.
All code is documented with dartdoc comments. Key areas:
- Game Engine (
lib/game/) - Core game logic and components - Services (
lib/services/) - Business logic, API integration, and ad management - UI Components (
lib/screens/,lib/widgets/) - User interface screens and widgets - Models (
lib/models/) - Data models and structures
See Documentation README for more information.
Made with ❤️ and 🦦
Happy Drifting! 🏞️