From e83ac8db4fe18f131e54692ccf78453537cd8896 Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Sat, 3 Feb 2024 21:02:57 +0100 Subject: [PATCH] added updatePlayerCell function to GameManager --- src/main/java/pacmanGame/Cell.java | 5 +++-- src/main/java/pacmanGame/GameManager.java | 4 ++++ src/main/java/pacmanGame/Player.java | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index 808cde1..db5751f 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -17,11 +17,13 @@ public class Cell { } public void triggerPill() { + this.type = "empty"; //todo: code } public void triggerFruit() { - //todo: code + this.type = "empty"; + map.gameManager.score += 505; } public void triggerItem() { @@ -38,5 +40,4 @@ public class Cell { System.out.println("cell contains no item!"); } } - } diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 818d0ed..9ecaa26 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -59,4 +59,8 @@ public class GameManager { } return false; } + + public void updatePlayerCell() { + map.GetCell(player.position).triggerItem(); + } } diff --git a/src/main/java/pacmanGame/Player.java b/src/main/java/pacmanGame/Player.java index fb8c3f0..b729254 100644 --- a/src/main/java/pacmanGame/Player.java +++ b/src/main/java/pacmanGame/Player.java @@ -24,6 +24,7 @@ public class Player { if(!newPosIsWall) { position = newPosition; } + gameManager.updatePlayerCell(); } public void processInput(char inputchar) {