Flame is a modular Flutter game engine that provides a complete set of out-of-the-way solutions for games. It takes advantage of the powerful infrastructure provided by Flutter but simplifies the code you need to build your projects. So, In this project I have created a basic "DinoRun" game.
- Flutter App
- Flame
- Android
- web
- Dino game like chrome
- Using flutter_flame.
- Add these dependencies in pubspec.yaml and hit Pub Get
dependencies |
---|
flutter_displaymode |
- use following function in MyApp's
initState()
to set maximum refresh rate to 60fps .
/// It set the max fps to 60.
refreshRate() async {
await FlutterDisplayMode.setLowRefreshRate();
}
-
DinoGame extends FlameGame class with TapDetector, HasCollisionDetection mixins which allows this class to perform taps and collision detection.
-
In GameOverlay widget I have taken a GameWidget in which I passed a Object of DinoGame
-
Dino is a class for Dino which contains method for animation,speed,jump,update and etc.
-
Enemy class works same as dino class but for the enemies.Which is managed by EnemyManager class.
-
DinoGame class manages all components of game either it is enemy or dino.
- Rutu Hirapara