Time for action – building the Tank class
We can build the Tank
class
using the following steps:
1. Add a new class file called
Tank.cs
to theTank Battles
project.2. Add the following
using
directives to the top of theTank.cs
class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
3. Add the following fields to the
Tank
class:#region Fields private Model model; private GraphicsDevice device; private Vector3 position; private float tankRotation; private float turretRotation; private float gunElevation; private Matrix baseTurretTransform; private Matrix baseGunTransform; private Matrix[] boneTransforms; #endregion
4. Add the following properties to the
Tank
class:#region Properties public Vector3 Position { get { return position; } set { position = value; } } public float TankRotation { get { return tankRotation; } set { tankRotation = MathHelper.WrapAngle(value); } ...