private void UpdateCamera(GameTime gameTime) { Camera.Rotate(MouseState.DeltaX * .005f, MouseState.DeltaY * .005f); var translation = Vector3.Zero; if (KeyboardState.IsWDown) translation += Vector3.Forward; if (KeyboardState.IsSDown) translation += Vector3.Backward; if (KeyboardState.IsADown) translation += Vector3.Left; if (KeyboardState.IsDDown) translation += Vector3.Right; // Move 3 units per millisecond, independent of frame rate translation *= 4 * gameTime.GetTotalMilliseconds(); Camera.Move(translation); Camera.Update(); }
private void UpdateModel(GameTime gameTime) { var rotationChange = new Vector3(0, 0, 0); // Determin which axes the ship should be rotated on, if any if (KeyboardState.IsWDown) rotationChange += new Vector3(1, 0, 0); if (KeyboardState.IsSDown) rotationChange += new Vector3(-1, 0, 0); if (KeyboardState.IsADown) rotationChange += new Vector3(0, 1, 0); if (KeyboardState.IsDDown) rotationChange += new Vector3(0, -1, 0); Models[0].Rotation += rotationChange * 0.025f; if (KeyboardState.IsSpaceNotDown) return; // Determine what direction to move in var rotation = Models[0].CreateFromYawPitchRoll(); // Move in the direction dictated by our rotation matrix Models[0].Position += Vector3.Transform(Vector3.Forward, rotation) * gameTime.GetTotalMilliseconds() * 4; }