using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using XnaGraphicEngine.Helpers; namespace XnaGraphicEngine.Game { /// /// Simple camera class just to move around a little. /// Always focuses on the center and uses the same height. /// class SimpleCamera : GameComponent { #region Variables float x = 0, y = 0; float zHeight = 15.0f; #endregion #region Constructor public SimpleCamera(BaseGame game) : base(game) { } // SimpleCamera(game) #endregion #region Initialize public override void Initialize() { base.Initialize(); } // Initialize #endregion #region Update public override void Update(GameTime gameTime) { base.Update(gameTime); // Update camera position (allow mouse and gamepad) x += Input.MouseXMovement / 10; y += Input.MouseYMovement / 10; x += Input.GamePad.ThumbSticks.Right.X; y += Input.GamePad.ThumbSticks.Right.Y; zHeight += Input.GamePad.ThumbSticks.Left.Y; zHeight += Input.MouseWheelDelta / 20; BaseGame.ViewMatrix = Matrix.CreateLookAt( new Vector3(x, y, zHeight), Vector3.Zero, Vector3.Up); } // Update(gameTime) #endregion } // class SimpleCamera } // namespace XnaGraphicEngine.Game