Skip to content

Commit 2bb3065

Browse files
Refac
1 parent a38a697 commit 2bb3065

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

pacman-core/src/main/java/de/amr/pacmanfx/controller/GameState.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void onUpdate(GameContext context) {
8181
static final short TICK_NEW_GAME_SHOW_GUYS = 120;
8282
static final short TICK_NEW_GAME_START_HUNTING = 240;
8383
static final short TICK_DEMO_LEVEL_START_HUNTING = 120;
84-
static final short TICK_RESUME_GAME = 90;
84+
static final short TICK_RESUME_HUNTING = 90;
8585

8686
@Override
8787
public void onEnter(GameContext context) {
@@ -91,13 +91,9 @@ public void onEnter(GameContext context) {
9191
@Override
9292
public void onUpdate(GameContext context) {
9393
if (context.game().isPlaying()) {
94-
// resume running game
9594
if (timer.tickCount() == 1) {
96-
context.game().resetPacManAndGhostAnimations();
97-
context.gameLevel().getReadyToPlay();
98-
context.gameLevel().showPacAndGhosts();
99-
context.eventManager().publishEvent(GameEventType.GAME_CONTINUED);
100-
} else if (timer.tickCount() == TICK_RESUME_GAME) {
95+
context.game().continueGame();
96+
} else if (timer.tickCount() == TICK_RESUME_HUNTING) {
10197
context.gameController().changeGameState(GameState.HUNTING);
10298
}
10399
}

pacman-core/src/main/java/de/amr/pacmanfx/model/AbstractGameModel.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public Optional<GameLevel> level() {
7575
return Optional.ofNullable(level);
7676
}
7777

78+
@Override
79+
public void continueGame() {
80+
resetPacManAndGhostAnimations();
81+
level.getReadyToPlay();
82+
level.showPacAndGhosts();
83+
eventManager().publishEvent(GameEventType.GAME_CONTINUED);
84+
}
85+
7886
@Override
7987
public void startHunting() {
8088
level.pac().playAnimation();

pacman-core/src/main/java/de/amr/pacmanfx/model/GameLifecycle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface GameLifecycle {
1111
void prepareForNewGame();
1212
boolean canStartNewGame();
1313
void startNewGame();
14+
void continueGame();
1415
void buildNormalLevel(int levelNumber);
1516
void buildDemoLevel();
1617
void createLevel(int levelNumber);

0 commit comments

Comments
 (0)