class Ship
{public Model Model;public Matrix[] Transforms;//Position of the model in world spacepublic Vector3 Position = Vector3.Zero;//Velocity of the model, applied each frame to the model's positionpublic Vector3 Velocity = Vector3.Zero;//amplifies controller speed inputprivateconstfloat VelocityScale =5.0f;publicbool isActive = true;public Matrix RotationMatrix = Matrix.CreateRotationX(MathHelper.PiOver2);privatefloat rotation;publicfloat Rotation
{
get {return rotation;}
set
{float newVal = value;while(newVal >= MathHelper.TwoPi){
newVal -= MathHelper.TwoPi;}while(newVal <0){
newVal += MathHelper.TwoPi;}if(rotation != value){
rotation = value;
RotationMatrix =
Matrix.CreateRotationX(MathHelper.PiOver2)*
Matrix.CreateRotationZ(rotation);}}}publicvoid Update(GamePadState controllerState){// Rotate the model using the left thumbstick, and scale it down.if(Math.Abs(controllerState.ThumbSticks.Left.X)>.2) Rotation -= controllerState.ThumbSticks.Left.X*0.10f;// Finally, add this vector to our velocity.
Velocity += RotationMatrix.Forward* VelocityScale *
controllerState.Triggers.Right;}}
Code for ship.cs