Time for action – creating the Maze classes
1. Add a new class file called
Maze.cs
to the Cube Chaser project.2. Add the following
using
directives to the top of theMaze.cs
class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Add the following fields to the
Maze
class:#region Fields public const int mazeWidth = 20; public const int mazeHeight = 20; GraphicsDevice device; VertexBuffer floorBuffer; Color[] floorColors = new Color[2] { Color.White, Color.Gray }; #endregion
4. Add a constructor for the
Maze
class:#region Constructor public Maze(GraphicsDevice device) { this.device = device; BuildFloorBuffer(); }#endregion
5. Add the following region and helper methods to the
Maze
class:#region The Floor private void BuildFloorBuffer() { List<VertexPositionColor> vertexList = new List<VertexPositionColor>(); int counter = 0; for (int x = 0; x < mazeWidth; x++) { counter++; for (int z = 0...