Time for action – building walls
1. Add the following to the declarations area of the
Maze
class:VertexBuffer wallBuffer; Vector3[] wallPoints = new Vector3[8]; Color[] wallColors = new Color[4] { Color.Red, Color.Orange, Color.Red, Color.Orange };
2. Add the following code to the end of the constructor in the
Maze
class to initialize thew
allPoints
array and build the walls:wallPoints[0] = new Vector3(0, 1, 0); wallPoints[1] = new Vector3(0, 1, 1); wallPoints[2] = new Vector3(0, 0, 0); wallPoints[3] = new Vector3(0, 0, 1); wallPoints[4] = new Vector3(1, 1, 0); wallPoints[5] = new Vector3(1, 1, 1); wallPoints[6] = new Vector3(1, 0, 0); wallPoints[7] = new Vector3(1, 0, 1); BuildWallBuffer();
3. Add the
BuildWallBuffe
r()
method to theMaze
class as follows:#region Walls private void BuildWallBuffer() { List<VertexPositionColor> wallVertexList = new List<VertexPositionColor>(); for (int x = 0; x < mazeWidth; x++) { for (int z = 0; z < mazeHeight...