diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 4abc105..8e9371f 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -28,7 +28,7 @@ public class Map { "ww............ww............ww", "ww.wwww.wwwww.ww.wwwww.wwww.ww", "ww.wwww.wwwww.ww.wwwww.wwww.ww", - "ww...ww................ww...ww", + "ww...ww.......s........ww...ww", "wwww.ww.ww.wwwwwwww.ww.ww.wwww", "wwww.ww.ww.wwwwwwww.ww.ww.wwww", "ww......ww....ww....ww......ww", @@ -41,6 +41,7 @@ public class Map { public final HashMap mapTypes = new HashMap(){{ this.put("e", "empty"); + this.put("s", "empty"); this.put(".", "dot"); this.put("w", "wall"); }}; @@ -48,6 +49,9 @@ public class Map { public Cell[][] cells; public Vector2 size; + public Vector2 playerSpawn = new Vector2(2,2); + public char playerSpawnChar = 's'; + public Map() { GenerateMap(mapClassic); } @@ -69,9 +73,15 @@ public class Map { for(int y = 0; y < size.y; y++) { Vector2 cellPos = new Vector2(x,y); - String cellType = mapTypes.get(String.valueOf(mapData[size.y - 1 - y].charAt(x))); + char cellChar = mapData[size.y - 1 - y].charAt(x); + + String cellType = mapTypes.get(String.valueOf(cellChar)); cells[x][y] = new Cell(cellPos, cellType); + + if(cellChar == playerSpawnChar) { + playerSpawn = cellPos.Clone(); + } } } }