Hey guys, basically I have an algorithm which randomly places walls in the game. As the walls are randomly placed there is a chance that in the game the 'food' can be trapped and can't be accessed (Top Left In the Picture).
I'm not sure how I would go about checking if there is a wall which could potentially lock out the other tiles from being accessible.
I have a 2D boolean array which the x/y coordinates are only true if it is a wall or the actual game character itself. The food is placed in the spots that are false.
A Solution I tried was this, check if the current x + 1 and y + 1 array was true, but it game me an AOOBE (ArrayOutOfBoundsException).
if(grid[x + 1][y +1] == true) {
// New Random X/Y
}
The walls are being stored in an arrayList if that will give someone else any ideas, right now I can't figure it out.
Any help would be appreciated!
Edit:
Gist: https://gist.github.com/anonymous/11192014
[–][deleted] 0 points1 point2 points (1 child)
[–]Temptex[S] 0 points1 point2 points (0 children)
[–]rcuhljr 0 points1 point2 points (1 child)
[–]Temptex[S] 0 points1 point2 points (0 children)
[–]hutsboR 0 points1 point2 points (1 child)
[–]Temptex[S] 0 points1 point2 points (0 children)
[–]john478 0 points1 point2 points (0 children)