I am currently, creating a maze game and am using an Array to assign my wall blocks. However, these blocks are always random except for the border. I need to create a path to ensure my characters can always fit through and there will always be an entrance and exit. Help? Attached below is the current array for randomly assigning them.
public class world extends World
{
private static final int SIZEY = 24;
private static final int SIZEX = 44;
private int mapArray = new int;
private int map = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0},
{1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0},
{1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1},
{1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1},
{1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}
};
/**
* Constructor for objects of class world.
*
*/
public world()
{
super(1100, 600, 1);
fillArray();
popMap();
}
public void fillArray()
{
for (int j=0; j<SIZEY; j++)
{
for (int i=0; i<SIZEX; i++)
{
if(i>0 && j>0 && i<SIZEX-1 && j<SIZEY-1)
{
mapArray=Greenfoot.getRandomNumber(2);
}
else {
mapArray = 1;
}
}
}
}
public void popMap()
{
for (int j=0; j<SIZEY; j++)
{
for (int i=0; i<SIZEX; i++)
{
if(mapArray == 1)
{
Wall wall = new Wall();
addObject(wall, ((i * 25) + 13), ((j * 25) + 13));
}
}
}
}
}

