Time for action – drawing the floor
1. Add the
Draw
region and theDraw()
method to theMaze
class:#region Draw public void Draw(Camera camera, BasicEffect effect) { effect.VertexColorEnabled = true; effect.World = Matrix.Identity; effect.View = camera.View; effect.Projection = camera.Projection; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(floorBuffer); device.DrawPrimitives( PrimitiveType.TriangleList, 0, floorBuffer.VertexCount / 3); } } #endregion
2. In the
CubeChaserGame
class, add the following declarations to the declarations area of the class:Camera camera; Maze maze; BasicEffect effect;
3. In the
Initialize()
method of theCubeChaserGame
class, initialize the camera, maze, and effect objects, placing this code before the call tob
ase.Initialize()
:camera = new Camera( new Vector3(0.5f, 0.5f, 0.5f), 0, GraphicsDevice.Viewport...