public override void Update(MXF.GameTime gameTime) { // Retrieve the mousestate inputManagerService.Mouse.Capture(); MouseState ms = inputManagerService.Mouse.MouseState; Keyboard kb = inputManagerService.Keyboard; Joystick gp = null; if (inputManagerService.GamePads.Count > 0) { gp = inputManagerService.GamePads[0]; } kb.Capture(); if (gp != null) { gp.Capture(); } // Save the offset between mousecoordinates, and the current mouse pos // Check if pressed the left mouse button if (!ms.IsButtonDown(MouseButtonID.Left)) { // Rotate camera this.camera.Rotate(ms.X.Relative * 0.005f, ms.Y.Relative * 0.005f, 0); } // Variable that controls the speed float speed = 35f; if ((kb.IsShiftState(Keyboard.ShiftState.Shift) && kb.IsKeyDown(KeyCode.Key_LSHIFT)) || (gp != null && gp.JoystickState.IsButtonDown(2))) { speed *= 2; } // Check for specified key presses if (kb.IsKeyDown(KeyCode.Key_W) || kb.IsKeyDown(KeyCode.Key_UP) || ms.IsButtonDown(MouseButtonID.Left)) { this.camera.Translate(new MXF.Vector3(0, 0, -1) * speed); } if (kb.IsKeyDown(KeyCode.Key_S) || kb.IsKeyDown(KeyCode.Key_DOWN)) { this.camera.Translate(new MXF.Vector3(0, 0, 1) * speed); } if (kb.IsKeyDown(KeyCode.Key_A) || kb.IsKeyDown(KeyCode.Key_LEFT)) { this.camera.Translate(new MXF.Vector3(-1, 0, 0) * speed); } if (kb.IsKeyDown(KeyCode.Key_D) || kb.IsKeyDown(KeyCode.Key_RIGHT)) { this.camera.Translate(new MXF.Vector3(1, 0, 0) * speed); } if (gp != null) { var xAxis = gp.JoystickState.Axis[0]; var yAxis = gp.JoystickState.Axis[1]; this.camera.Rotate(xAxis.Absolute * 0.005f, yAxis.Absolute * 0.005f, 0); } // TODO: Add your update code here base.Update(gameTime); }