Time for action – beginning the MarsTrack class
To create a track for the player to drive on, perform the following steps:
1. Add a new class file called
MarsTrack.cs
to theMars Runner
project.2. Add the following
using
directives to the top of theMarsTrack
class file:using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework;
3. Add fields to the
MarsTrack
class as follows:#region Fields private GraphicsDevice device; private Texture2D marsTexture; private List<VertexBuffer> vertexBuffers = new List<VertexBuffer>(); private List<IndexBuffer> indexBuffers = new List<IndexBuffer>(); private float terrainScale = 30f; private int[] track; #endregion
4. Add a constructor to the
MarsTrack
class as follows:#region Constructor public MarsTrack(GraphicsDevice device, ContentManager content) { this.device = device; track = GenerateTrack(100); marsTexture = content.Load<Texture2D>(@"Textures\mars_surface...