Time for action – drawing the walls
1. In the
Draw()
method of theMaze
class, after the existing call todevi
ce.DrawPrimitives()
, add the following lines of code:device.SetVertexBuffer(wallBuffer); device.DrawPrimitives( PrimitiveType.TriangleList, 0, wallBuffer.VertexCount / 3);
2. Execute your game and wander around in the maze:
What just happened?
Since the result of all of our wall generation code is to create another vertex buffer, all we need to do to draw the walls is to pass the buffer along to the graphics device, just like we did with the floor buffer.
You will notice, however, that you can walk right through all of the walls in the maze, which makes finding your way around a bit less than challenging.