Skip to content

Commit

Permalink
add world map when game start and stop
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeungJayJang committed Feb 1, 2024
1 parent f8ab979 commit c5af311
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/components/character/guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Guard extends Character with HasGameReference<StackRPGGame> {
this.turnBack();
} else if (sight.seenObject is MainCharacter) {
game.found = true;
map!.removeFromParent();
} else if (sight.seenObject is Sight) {
this.turnBack();
// if (direction.index % 2 == 0) {
Expand Down
1 change: 1 addition & 0 deletions lib/overlays/main_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MainMenu extends StatelessWidget {
height: 75,
child: ElevatedButton(
onPressed: () {
game.initialize();
game.overlays.remove('MainMenu');
},
style: ElevatedButton.styleFrom(
Expand Down
6 changes: 4 additions & 2 deletions lib/stack_rpg_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class StackRPGGame extends FlameGame
// add components
// ------------------------------------------
add(Hud());
world.add(map);

// ------------------------------------------
// set the camera to fix to lands.
Expand Down Expand Up @@ -150,11 +149,14 @@ class StackRPGGame extends FlameGame
}
}

void initialize() {
world.add(map);
}

void reset() {
gameLevel = 1;
point = 0;
found = false;
map.removeFromParent();
map = Map(
landCountX: landCountX,
landCountY: landCountY,
Expand Down

0 comments on commit c5af311

Please # to comment.