A captivating physics-based puzzle game featuring swirling gravity mechanics. Guide particles through cosmic gravity wells by drawing paths with your finger or mouse. Built with pure Flutter using CustomPaint — no external game engine required.
Navigate particles through space by guiding them with touch/mouse input. The particles are attracted to gravity wells placed around the level. Your goal is to collect all goal markers to complete each level.
| Technology | Purpose |
|---|---|
| Flutter 3.24 | Cross-platform UI framework |
| CustomPaint | Hardware-accelerated canvas rendering |
| ChangeNotifier | Reactive state management |
| Dart | Programming language |
| GitHub Actions | CI/CD automation |
| GitHub Pages | Static hosting |
gravity_swirl_game/
├── lib/
│ └── main.dart # Single-file game: physics engine, UI, screens
├── web/
│ └── index.html # Web entry point
├── pubspec.yaml # Dependencies & metadata
├── analysis_options.yaml # Linting rules
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Actions CI/CD workflow
└── README.md # Documentation
# Clone the repository
git clone https://github.com/govindtank/gravity-swirl-game.git
cd gravity-swirl-game
# Install dependencies
flutter pub get
# Run on Chrome (Web)
flutter run -d chrome
# Run on connected device
flutter run
# Build for production (Web)
flutter build web --release --base-href /gravity-swirl-game/
# Run with hot reload
flutter run
# Analyze code
flutter analyze
# Run tests
flutter test
| Component | Description |
|---|---|
GravitySwirlGameEngine |
Physics engine with gravity well simulation and particle movement |
GameState |
Holds game data: score, level, particles, goals, repulsion zones |
GameCanvas |
StatefulWidget with AnimationController for 60fps game loop |
GamePainter |
CustomPainter rendering all game elements to canvas |
HomeScreen |
Animated landing page with gradient background |
dependencies:
flutter:
sdk: flutter
The project uses GitHub Actions for automated deployment:
main branch or manual workflow dispatch--base-href /gravity-swirl-game/View the workflow: .github/workflows/deploy.yml
import 'package:gravity_swirl_game/sounds/audio_manager.dart';
// Create audio manager singleton
final audioManager = AudioManager();
// Play sound when particle is collected
audioManager.play(AudioManager.Effect.particleCollect);
// Toggle mute globally
audioManager.toggleMute(true);
import 'package:gravity_swirl_game/settings/settings_screen.dart';
// Add to app navigation
Scaffold(
body: Stack(
children: [
GameCanvas(),
Positioned(
top: 10,
right: 10,
child: IconButton(
icon: const Icon(Icons.settings),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => SettingsScreen()),
),
),
),
],
),
);
Modify force magnitudes in GravitySwirlGameEngine.update():
// Adjust gravity well attraction strength
double forceMagnitude = 1.5 / (distance * distance);
// Adjust damping rate
particle.velocity = particle.velocity * 0.95; // Try: 0.92 for stronger damping
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Govind Tank - GitHub
Made with ❤️ using Flutter