Added highscore
This commit is contained in:
@ -29,7 +29,6 @@ public class GhostManager {
|
||||
public static final int CLYDE_ANIMATION = 3;
|
||||
@Getter
|
||||
private final List<Ghost> ghosts = new ArrayList<>();
|
||||
private final LevelManager levelManager;
|
||||
|
||||
private long lastModeSwitchTime;
|
||||
private int phaseIndex = 0;
|
||||
@ -44,7 +43,6 @@ public class GhostManager {
|
||||
private boolean frozen;
|
||||
|
||||
public GhostManager(GhostCollisionChecker ghostCollisionChecker, AnimationManager animationManager, LevelManager levelManager) {
|
||||
this.levelManager = levelManager;
|
||||
// Create ghosts with their strategies
|
||||
Ghost blinky = new Ghost(ghostCollisionChecker, new BlinkyStrategy(), new ScatterToTopRight(), BLINKY_ANIMATION, levelManager);
|
||||
ghosts.add(blinky);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package se.urmo.game.state;
|
||||
|
||||
import lombok.Getter;
|
||||
import se.urmo.game.main.GamePanel;
|
||||
import se.urmo.game.main.GameStateManager;
|
||||
import se.urmo.game.main.HighScoreManager;
|
||||
@ -14,6 +15,7 @@ public class GameOverState implements GameState {
|
||||
private final GameStateManager gsm;
|
||||
private int finalScore = 0;
|
||||
private int finalLevel = 0;
|
||||
@Getter
|
||||
private final HighScoreManager highScores; // optional
|
||||
|
||||
private boolean saved = false;
|
||||
|
||||
@ -178,6 +178,10 @@ public class PlayingState implements GameState {
|
||||
g.drawString("Your Score", 48, 48);
|
||||
g.drawString("" + score, 48, 72);
|
||||
|
||||
// High Score (above map, right)
|
||||
g.drawString("High Score", 248, 48);
|
||||
g.drawString("" + gameOverState.getHighScores().top().stream().findFirst().orElse(0), 248, 72);
|
||||
|
||||
// Lives (below map, left)
|
||||
for (int i = 1; i < lives; i++) {
|
||||
g.drawImage(pacman.getLifeIcon(),
|
||||
|
||||
Reference in New Issue
Block a user