added walls to map

This commit is contained in:
Jalen Winslow 2017-11-06 14:10:05 -07:00
parent a4a77fb8dd
commit c0e9f5feef
3 changed files with 45 additions and 2 deletions

Binary file not shown.

View File

@ -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

View File

@ -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() {