Skip to content

Commit

Permalink
reset scores on game reset
Browse files Browse the repository at this point in the history
  • Loading branch information
aruhant committed Feb 8, 2024
1 parent 64e3392 commit e67dc6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/lib/game/game_engine.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:bonfire/bonfire.dart';
import 'package:flutter/foundation.dart';
import 'package:ramayana/game/ui/score_controller.dart';
import 'package:ramayana/game/ui/score_widget.dart';
import 'package:ramayana/title_screen/title_screen.dart';
import 'package:ramayana/user_prefs/audioController.dart';
Expand Down Expand Up @@ -392,6 +393,7 @@ class _GameEngineState extends State<GameEngine> {

void reset() {
setState(() {
ProgressBarController().reset();
_gameKey = UniqueKey();
});
}
Expand Down
11 changes: 9 additions & 2 deletions app/lib/game/ui/score_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ class ProgressBarController extends ChangeNotifier {
ProgressBarController._internal();

double _life = 0;
int _goals = 0;
int _enemies = 0;
int _goals = 28;
int _enemies = 15;

reset() {
_life = 0;
_goals = 28;
_enemies = 15;
notifyListeners();
}

double get life => _life;
int get goals => _goals;
Expand Down

0 comments on commit e67dc6c

Please sign in to comment.