Time for action – drawing the track
To draw the track for Mars Runner, perform the following steps:
1. Add the
Draw
region and its two methods to theMarsTrack
class as follows:#region Draw public void Draw(Camera camera, BasicEffect effect, float offset) { effect.View = camera.View; effect.Projection = camera.Projection; effect.TextureEnabled = true; effect.Texture = marsTexture; effect.EnableDefaultLighting(); float drawBase = 60f; drawBase += offset % 30f; int firstSector = (int)(offset / 30f); for (int x = 0; x < 5; x++) { if (firstSector + x >= 0 && firstSector + x < track.Length) { DrawTerrainMeshInstance( track[firstSector + x], effect, drawBase - (x * 30f)); } } } private void DrawTerrainMeshInstance( int meshIndex, BasicEffect effect, float horizontalOffset) { effect.World = Matrix.Identity * Matrix.CreateTranslation...