Time for action –building the rover
To build the player's rover, perform the following steps:
1. Add a new class file called
Rover.cs
to theMars Runner
project.2. Add the following
using
directives to the top of theRover
class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Modify the declaration of the
Rover
class to inherit fromGameEntity
. The new class declaration should read as follows:class Rover : GameEntity
4. Add a constructor for the
Rover
class as follows:#region Constructor public Rover(GraphicsDevice device, Model model, Vector3 position) : base(device, model, position) { scale = 0.015f; yaw = MathHelper.ToRadians(90); currentTransforms["canon_geo"] = Matrix.CreateRotationX(MathHelper.ToRadians(-90)) * baseTransforms["canon_geo"]; } #endregion
5. In the
MarsRunnerPlayScreen
class, add a new field to hold an instance of theRover
class as follows:Rover rover;
6. In the
LoadContent()
method of theMarsRunnerPlayScreen...