diff --git a/build/com/hobogames/utils/Map.class b/build/com/hobogames/utils/Map.class index 69cef8b..55efaef 100644 Binary files a/build/com/hobogames/utils/Map.class and b/build/com/hobogames/utils/Map.class differ diff --git a/res/maps/Game1_tutorialMap.txt b/res/maps/Game1_tutorialMap.txt index 29fb22a..e210d3b 100644 --- a/res/maps/Game1_tutorialMap.txt +++ b/res/maps/Game1_tutorialMap.txt @@ -9,6 +9,7 @@ hall 23 2 3 1 hall 0 7 4 1 hall 7 8 6 1 hall 17 9 1 3 +make_walls switch 17 11 1 lock_door 12 8 1 exit 0 7 diff --git a/src/com/hobogames/utils/Map.java b/src/com/hobogames/utils/Map.java index 967fc87..c595361 100644 --- a/src/com/hobogames/utils/Map.java +++ b/src/com/hobogames/utils/Map.java @@ -39,6 +39,25 @@ public class Map { } } break; + case "make_walls": + for (int j = 0; j < mapData.length; j++) { + for (int i = 0; i < mapData[j].length; i++) { + String wall = "%"; + if (j+1 != mapData.length && mapData[j+1][i] != null && + mapData[j+1][i].equals(".") && mapData[j][i] == null) + mapData[j][i] = wall; + if (j-1 != -1 && mapData[j-1][i] != null && + mapData[j-1][i].equals(".") && mapData[j][i] == null) + mapData[j][i] = wall; + if (i+1 != mapData[j].length && mapData[j][i+1] != null && + mapData[j][i+1].equals(".") && mapData[j][i] == null) + mapData[j][i] = wall; + if (i-1 != -1 && mapData[j][i-1] != null && + mapData[j][i-1].equals(".") && mapData[j][i] == null) + mapData[j][i] = wall; + } + } + break; case "switch": mapData[Integer.parseInt(object[2])][Integer.parseInt(object[1])] = "S"; break; @@ -62,8 +81,31 @@ public class Map { break; } } + for (int j = 0; j < mapData.length; j++) { for (int i = 0; i < mapData[j].length; i++) { + if (mapData[j][i] == null) mapData[j][i] = " "; + } + } + /* + for (int j = 0; j < mapData.length; j++) { + for (int i = 0; i < mapData[j].length; i++) { + if (mapData[j][i] == null) { + if (j+1 != mapData.length) { + if (mapData[j+1][i] != null) mapData[j][i] = "#"; + } + if (j-1 != -1) { + if (mapData[j-1][i] != null) mapData[j][i] = "#"; + } + if (i+1 != mapData[j].length) { + if (mapData[j][i+1] != null) mapData[j][i] = "#"; + } + if (i-1 != -1) { + if (mapData[j][i-1] != null) mapData[j][i] = "#"; + } + } + + /* if (mapData[j][i] == null) { if (j+1 != mapData.length && i+1 != mapData[j].length && (mapData[j+1][i] != null || mapData[j][i+1] != null)) { @@ -74,9 +116,9 @@ public class Map { mapData[j][i] = "#"; } else mapData[j][i] = " "; - } + }// } - } + } */ } public void displayMap() {