Adding fruits

This commit is contained in:
Urban Modig
2025-08-30 08:45:43 +02:00
parent 23fce8dded
commit 63b2b7ae68
8 changed files with 150 additions and 9 deletions

View File

@ -23,6 +23,8 @@ public class PlayingState implements GameState {
private final GameStateManager gameStateManager;
private final GhostManager ghostManager;
private final Font arcadeFont;
private final FruitManager fruitManager;
private final LevelManager levelManager;
private PacMan pacman;
@Getter
private GameMap map;
@ -35,6 +37,8 @@ public class PlayingState implements GameState {
this.map = new GameMap("maps/map1.csv");
this.pacman = new PacMan(game, new CollisionChecker(map));
this.ghostManager = new GhostManager(new GhostCollisionChecker(map));
this.fruitManager = new FruitManager();
this.levelManager = new LevelManager();
this.arcadeFont = loadArcadeFont();
}
@ -42,6 +46,7 @@ public class PlayingState implements GameState {
public void update() {
pacman.update();
ghostManager.update(pacman, map);
fruitManager.update(pacman, this);
checkCollisions();
handleDots();
}
@ -54,6 +59,7 @@ public class PlayingState implements GameState {
ghostManager.setFrightMode();
}
if(wasRemoved){
fruitManager.dotEaten();
score+=tile.getTileType().getScore();
}
}
@ -63,6 +69,7 @@ public class PlayingState implements GameState {
map.draw(g);
pacman.draw(g);
ghostManager.draw(g);
fruitManager.draw(g);
drawUI(g);
}
@ -129,4 +136,8 @@ public class PlayingState implements GameState {
return new Font("Monospaced", Font.BOLD, 16);
}
}
public void setScore(int score) {
this.score += score;
}
}