Browse Source

updated Uptdate to check if ghostIsEdible needs to be turned off in GameManager

remotes/origin/player
fdai7910 11 months ago
parent
commit
2a54b4bdd0
  1. 3
      src/main/java/pacmanGame/Cell.java
  2. 14
      src/main/java/pacmanGame/GameManager.java

3
src/main/java/pacmanGame/Cell.java

@ -20,8 +20,9 @@ public class Cell {
public void triggerPill() { public void triggerPill() {
this.type = "empty"; this.type = "empty";
gameManager.score += 100; gameManager.score += 100;
int timeStopPillEffect = gameManager.time + 200;
gameManager.timeStopPillEffect = gameManager.time + 200;
gameManager.ghostIsEdible = true; gameManager.ghostIsEdible = true;
} }
public void triggerFruit() { public void triggerFruit() {

14
src/main/java/pacmanGame/GameManager.java

@ -7,7 +7,8 @@ public class GameManager {
public Visualizer visualizer; public Visualizer visualizer;
public Player player; public Player player;
public int score = 0; public int score = 0;
public Boolean ghostIsEdible = false;
public boolean ghostIsEdible = false;
public int timeStopPillEffect;
public GameManager() { public GameManager() {
setupGame(); setupGame();
@ -35,6 +36,10 @@ public class GameManager {
if (time == 600) { if (time == 600) {
destroyCherry(); destroyCherry();
} }
if(ghostIsEdible) {
if(time == timeStopPillEffect)
ghostIsEdible = false;
}
time++; time++;
} }
@ -78,11 +83,4 @@ public class GameManager {
public void updatePlayerCell() { public void updatePlayerCell() {
map.GetCell(player.position).triggerItem(); map.GetCell(player.position).triggerItem();
} }
public void makeGhostEdible(int timeStopPillEffect) {
ghostIsEdible = true;
if(time == timeStopPillEffect) {
ghostIsEdible = false;
}
}
} }
Loading…
Cancel
Save