Adding fruits
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user