Let ghosts already returning continue when another ghost is caught

Only catch one ghost per frame
Fix new game shortcut
This commit is contained in:
Matt Low 2020-01-05 23:28:23 +04:00
parent 2bc78baa74
commit 13d1948d48

View File

@ -407,8 +407,8 @@ public class PlayState extends LevelState {
ghostCaught(ghost); ghostCaught(ghost);
} else if (!(ghost.currentBehaviour instanceof ReturnToBase)) { } else if (!(ghost.currentBehaviour instanceof ReturnToBase)) {
pacmanCaught(); pacmanCaught();
return true;
} }
return true;
} }
return false; return false;
} }
@ -454,13 +454,21 @@ public class PlayState extends LevelState {
} }
} }
break; break;
default: case GHOST_CAUGHT_POINTS_WAIT:
stateTimer -= dt; for (Ghost ghost : ghosts) {
if (stateTimer <= 0) { if (ghost.currentBehaviour instanceof ReturnToBase && ghost != lastGhostCaptured) {
stateTransition(); ghost.update(dt);
}
} }
break; break;
} }
if (state.timer > 0) {
stateTimer -= dt;
if (stateTimer <= 0) {
stateTransition();
}
}
} }
private final class Controller extends InputAdapter { private final class Controller extends InputAdapter {
@ -490,6 +498,7 @@ public class PlayState extends LevelState {
break; break;
case Input.Keys.N: case Input.Keys.N:
preNewGame(); preNewGame();
setGameState(GameState.PRE_NEW_GAME);
break; break;
} }
return super.keyDown(keycode); return super.keyDown(keycode);