Time for action – bouncing off the walls
1. Add the
BuildBoundingBox()
method to theWalls
region of theMaze
class as follows:private BoundingBox BuildBoundingBox( int x, int z, int point1, int point2) { BoundingBox thisBox = new BoundingBox( wallPoints[point1], wallPoints[point2]); thisBox.Min.X += x; thisBox.Min.Z += z; thisBox.Max.X += x; thisBox.Max.Z += z; thisBox.Min.X -= 0.1f; thisBox.Min.Z -= 0.1f; thisBox.Max.X += 0.1f; thisBox.Max.Z += 0.1f; return thisBox; }
2. Add the
GetBoundsForCell()
method to theWalls
region of theMaze
class:public List<BoundingBox> GetBoundsForCell(int x, int z) { List<BoundingBox> boxes = new List<BoundingBox>(); if (MazeCells[x, z].Walls[0]) boxes.Add(BuildBoundingBox(x, z, 2, 4)); if (MazeCells[x, z].Walls[1]) boxes.Add(BuildBoundingBox(x, z, 6, 5)); if (MazeCells[x, z].Walls[2]) boxes.Add(BuildBoundingBox(x, z...