Deathanimation working
This commit is contained in:
@ -88,22 +88,19 @@ public class PlayingState implements GameState {
|
||||
case LIFE_LOST -> {
|
||||
// Freeze, then reset round (keep dot state)
|
||||
if (phaseElapsed() >= LIFE_LOST_MS) {
|
||||
pacman.reset();
|
||||
deathInProgress = false;
|
||||
resetAfterLifeLost();
|
||||
ghostManager.setFrozen(false);
|
||||
setPhase(RoundPhase.READY);
|
||||
if (lives <= 0) {
|
||||
endGame();
|
||||
}
|
||||
}
|
||||
pacman.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAfterLifeLost() {
|
||||
pacman.reset(); // to start tile, direction stopped
|
||||
ghostManager.reset(); // to house
|
||||
}
|
||||
|
||||
private void advanceLevel() {
|
||||
levelManager.nextLevel();
|
||||
map.reset();
|
||||
@ -142,8 +139,8 @@ public class PlayingState implements GameState {
|
||||
@Override
|
||||
public void render(Graphics2D g) {
|
||||
map.draw(g);
|
||||
pacman.draw(g);
|
||||
ghostManager.draw(g);
|
||||
pacman.draw(g);
|
||||
fruitManager.draw(g);
|
||||
drawUI(g);
|
||||
|
||||
@ -215,6 +212,8 @@ public class PlayingState implements GameState {
|
||||
ghost.resetPosition();
|
||||
ghost.setMode(GhostMode.CHASE); // end frightend
|
||||
} else {
|
||||
ghostManager.setFrozen(true);
|
||||
pacman.startDeathAnimation();
|
||||
deathInProgress = true;
|
||||
// Pac-Man loses a life
|
||||
lives--;
|
||||
|
||||
Reference in New Issue
Block a user