From 13d1948d48f2662e928acc3ddf56797a021ca1be Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sun, 5 Jan 2020 23:28:23 +0400 Subject: [PATCH] Let ghosts already returning continue when another ghost is caught Only catch one ghost per frame Fix new game shortcut --- core/src/com/me/pacman/state/PlayState.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index f828d7e..1425cae 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -407,8 +407,8 @@ public class PlayState extends LevelState { ghostCaught(ghost); } else if (!(ghost.currentBehaviour instanceof ReturnToBase)) { pacmanCaught(); - return true; } + return true; } return false; } @@ -454,13 +454,21 @@ public class PlayState extends LevelState { } } break; - default: - stateTimer -= dt; - if (stateTimer <= 0) { - stateTransition(); + case GHOST_CAUGHT_POINTS_WAIT: + for (Ghost ghost : ghosts) { + if (ghost.currentBehaviour instanceof ReturnToBase && ghost != lastGhostCaptured) { + ghost.update(dt); + } } break; } + + if (state.timer > 0) { + stateTimer -= dt; + if (stateTimer <= 0) { + stateTransition(); + } + } } private final class Controller extends InputAdapter { @@ -490,6 +498,7 @@ public class PlayState extends LevelState { break; case Input.Keys.N: preNewGame(); + setGameState(GameState.PRE_NEW_GAME); break; } return super.keyDown(keycode);