This is the code that create the map variable array of 0 and 1:
public static int[,] CreateArray(int numberOfRows, int numberOfCols)
{
int[,] map = new int[numberOfRows, numberOfCols];
for (int i = 0; i < numberOfRows; ++i)
{
Random rnd = new Random();
for (int j = 0; j < numberOfCols; ++j)
{
map[i, j] = rnd.Next(0, 2);
}
}
return map;
}
And this is how i use it call the method:
int[,] map = CreateArray(8, 8);
But each time i'm running the game i'm getting a different map like this: This is an image of two random maps i merged them to one image:
But i want to get random path the blue color which is the number 1 in the array if im not mistake i want to create like randon path with it. For example this is a map if i make the array of 0 and 1 manualy:
int[,] map = new int[,]
{
{0,0,1,0,0,0,0,0,},
{0,0,1,1,0,0,0,0,},
{0,0,0,1,1,0,0,0,},
{0,0,0,0,1,0,0,0,},
{0,0,0,1,1,0,0,0,},
{0,0,1,1,0,0,0,0,},
{0,0,1,0,0,0,0,0,},
{0,0,1,1,1,1,1,1,},
};
And the result is:
I'm using xna with two images to draw the green and blue. But the problem is to create the random map each time with a random path and not just blue color and green.