Browse Source

Added PlayerSpawn to Map

remotes/origin/menu
Julian 11 months ago
parent
commit
73832db295
  1. 14
      src/main/java/pacmanGame/Map.java

14
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<String, String> mapTypes = new HashMap<String,String>(){{
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();
}
}
}
}

Loading…
Cancel
Save