Browse Source

added reference from Map to GameManager

remotes/origin/menu
fdai7910 11 months ago
parent
commit
d93047ffac
  1. 2
      src/main/java/pacmanGame/GameManager.java
  2. 4
      src/main/java/pacmanGame/Map.java
  3. 8
      src/test/java/pacmanTests/MapTest.java
  4. 4
      src/test/java/pacmanTests/VisualizerPlainTextTest.java

2
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();

4
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) {

8
src/test/java/pacmanTests/MapTest.java

@ -22,7 +22,9 @@ 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;
@ -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];

4
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);

Loading…
Cancel
Save