2D Array Problem

Hi there, I've been trying to place an array into another within a 2D array. I can get one array to work fine but when I try to place another the program crashes. For example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
                        for (int i = randRoomSize; i <= randRoomSize; i++)
			{
				for (int j = randRoomSize; j <= randRoomSize; j++)
				{
					m_DungeonArray[i][j] = i*j;	
					
				}	
			}

			for (int x = randRoomNo; x <= randRoomNo; x++)
			{
				for (int y = randRoomNo; y <= randRoomNo; y++)
				{
					m_DungeonArray[x][y] = x*y;
				}
			}


Can someone help me on my way with the best method to go about this? Currently my program displays the 2d array in DirectX but all I have managed is filling the grid with wall blocks and the placement of one room. Would be good to get the random rooms scattered about the array. Can anyone help me?
Last edited on
to randomly scatter a RoomSize*RoomSize 2d array try this:
1
2
3
4
for (int i = 0 ; i < RoomSize; ++i)
  std::random_shuffle(m_MazeArray[i], m_MazeArray[i] + RoomSize);

std::random_shuffle(m_MazeArray, m_MazeArray + RoomSize);


Otherwise, I'd suggest that randRoomSize or randRoomNo are out of bounds.
Last edited on
Topic archived. No new replies allowed.