diff --git a/src/main/java/pacmanGame/GameManager.java b/src/main/java/pacmanGame/GameManager.java index 2d5ae52..c33d0ac 100644 --- a/src/main/java/pacmanGame/GameManager.java +++ b/src/main/java/pacmanGame/GameManager.java @@ -13,7 +13,7 @@ public class GameManager { } public void setupGame(){ - map = new Map(Map.mapClassic); + map = new Map(Map.mapClassic,this); visualizer = new VisualizerPlainText(this); player = new Player(this); player.Spawn(); diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 7f5e7d4..ce72d36 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -4,6 +4,7 @@ import java.util.HashMap; public class Map { + public final GameManager gameManager; public static String[] mapClassic = { "wwwwwwwwwwwwwwwwwwwwwwwwwwwwww", "wwwwwwwwwwwwwwwwwwwwwwwwwwwwww", @@ -53,8 +54,9 @@ public class Map { public Vector2 playerSpawn = new Vector2(2,2); public char playerSpawnChar = 's'; - public Map(String[] mapData) { + public Map(String[] mapData, GameManager gameManager) { GenerateMap(mapData); + this.gameManager = gameManager; } public void GenerateMap(String[] mapData) { diff --git a/src/test/java/pacmanTests/MapTest.java b/src/test/java/pacmanTests/MapTest.java index cc94256..f94d0bd 100644 --- a/src/test/java/pacmanTests/MapTest.java +++ b/src/test/java/pacmanTests/MapTest.java @@ -22,8 +22,10 @@ class MapTest { String expectedMiddle = "dot"; String expectedBottomRight = "dot"; // act - Map testMap = new Map(mapTest); - + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + Map testMap = gameManager.map; + String topLeft = testMap.cells[0][2].type; String middle = testMap.cells[1][1].type; String bottomRight = testMap.cells[2][0].type; @@ -41,7 +43,9 @@ class MapTest { "w..", "ee." }; - Map testMap = new Map(mapTest); + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + Map testMap = gameManager.map; Cell expectedTopLeft = testMap.cells[0][2]; Cell expectedMiddle = testMap.cells[1][1]; Cell expectedBottomRight = testMap.cells[2][0]; diff --git a/src/test/java/pacmanTests/VisualizerPlainTextTest.java b/src/test/java/pacmanTests/VisualizerPlainTextTest.java index 92276e2..e73225c 100644 --- a/src/test/java/pacmanTests/VisualizerPlainTextTest.java +++ b/src/test/java/pacmanTests/VisualizerPlainTextTest.java @@ -20,7 +20,7 @@ class VisualizerPlainTextTest { }; GameManager gameManager = new GameManager(); - gameManager.map = new Map(mapTest); + gameManager.map = new Map(mapTest, gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager); String expected = "" @@ -44,7 +44,7 @@ class VisualizerPlainTextTest { }; GameManager gameManager = new GameManager(); - gameManager.map = new Map(mapTest); + gameManager.map = new Map(mapTest, gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager); gameManager.ghosts[0].position = new Vector2(1, 1);