From 812dadfd12cb67666fff2ed273a9a7f9ae311eee Mon Sep 17 00:00:00 2001 From: fdai2751 Date: Thu, 18 Jan 2024 17:25:10 +0100 Subject: [PATCH] added Ghosts to GameManager --- src/main/java/pacmanGame/GameManager.java | 6 +++++- src/main/java/pacmanGame/Ghost.java | 6 ++++++ src/main/java/pacmanGame/GhostBehavior.java | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 40bae37..16e7e23 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -2,7 +2,7 @@ package pacmanGame; public class GameManager { public int time = 0; - + public Ghost[] ghosts; public Map map; public Visualizer visualizer; public Player player; @@ -11,6 +11,10 @@ public class GameManager { map = new Map(); visualizer = new VisualizerPlainText(this); player = new Player(this); + ghosts = new Ghost[4]; + for(int i = 0; i< ghosts.length; i++) { + ghosts[i] = new Ghost(); + } } public void Update() { diff --git a/src/main/java/pacmanGame/Ghost.java b/src/main/java/pacmanGame/Ghost.java index 0a3be13..388fbc7 100644 --- a/src/main/java/pacmanGame/Ghost.java +++ b/src/main/java/pacmanGame/Ghost.java @@ -2,4 +2,10 @@ package pacmanGame; public class Ghost { public Vector2 position; + public final GameManager gameManager; + + public Ghost(GameManager gameManager) { + this.gameManager = new GameManager(); + } + } diff --git a/src/main/java/pacmanGame/GhostBehavior.java b/src/main/java/pacmanGame/GhostBehavior.java index c71c458..5d0cacd 100644 --- a/src/main/java/pacmanGame/GhostBehavior.java +++ b/src/main/java/pacmanGame/GhostBehavior.java @@ -2,4 +2,6 @@ package pacmanGame; public interface GhostBehavior { public Vector2 GetDirection(); + + }