From 2954a0c8667c70e6f6257cd129d78b4b94928831 Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Mon, 5 Feb 2024 22:16:56 +0100 Subject: [PATCH] fixed nullPointerException in Cell --- src/main/java/pacmanGame/Cell.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index 23f698e..ddafff3 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -19,9 +19,9 @@ public class Cell { public void triggerPill() { this.type = "empty"; - gameManager.score += 100; - gameManager.timeStopPillEffect = gameManager.time + 200; - gameManager.ghostIsEdible = true; + map.gameManager.score += 100; + map.gameManager.timeStopPillEffect = map.gameManager.time + 200; + map.gameManager.ghostIsEdible = true; } @@ -45,6 +45,8 @@ public class Cell { map.gameManager.score += 205; } + + public void triggerItem() { if(type.equals("dot")) { triggerDot(); @@ -64,6 +66,7 @@ public class Cell { else if(type.equals("apple")) { triggerApple(); } + else { //System.out.println("cell contains no item!"); }