From 2a54b4bdd0bc2e3b4802c24490aa6aa33ff3df05 Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 19:48:24 +0100 Subject: [PATCH] updated Uptdate to check if ghostIsEdible needs to be turned off in GameManager --- src/main/java/pacmanGame/Cell.java | 3 ++- src/main/java/pacmanGame/GameManager.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index a077a59..f9cd74b 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -20,8 +20,9 @@ public class Cell { public void triggerPill() { this.type = "empty"; gameManager.score += 100; - int timeStopPillEffect = gameManager.time + 200; + gameManager.timeStopPillEffect = gameManager.time + 200; gameManager.ghostIsEdible = true; + } public void triggerFruit() { diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 6c60efb..544b401 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -7,7 +7,8 @@ public class GameManager { public Visualizer visualizer; public Player player; public int score = 0; - public Boolean ghostIsEdible = false; + public boolean ghostIsEdible = false; + public int timeStopPillEffect; public GameManager() { setupGame(); @@ -35,6 +36,10 @@ public class GameManager { if (time == 600) { destroyCherry(); } + if(ghostIsEdible) { + if(time == timeStopPillEffect) + ghostIsEdible = false; + } time++; } @@ -78,11 +83,4 @@ public class GameManager { public void updatePlayerCell() { map.GetCell(player.position).triggerItem(); } - - public void makeGhostEdible(int timeStopPillEffect) { - ghostIsEdible = true; - if(time == timeStopPillEffect) { - ghostIsEdible = false; - } - } }