private void OnAnalogMove(object sender, GamePadStateEventArgs gamePadStateEventArgs) { // http://plasticsturgeon.com/2012/08/rotate-the-shortest-direction/ var originalRotation = this.Player.Rotation; var targetRotation = ((float)Math.Atan2(gamePadStateEventArgs.GamePadState.ThumbSticks.Left.Y, gamePadStateEventArgs.GamePadState.ThumbSticks.Left.X)) * -1; // Todo: Why do have to invert? var rotationDifference = (float)Math.Atan2(Math.Sin(targetRotation - originalRotation), Math.Cos(targetRotation - originalRotation)); this.Player.SetRotationDelta(rotationDifference * 0.05f); this.AccumulateThrust(); this.TranslateShip(); }
private void OnAnalogFire(object sender, GamePadStateEventArgs gamePadStateEventArgs) { var originalRotation = this.Player.Weapon.Rotation; var targetRotation = ((float)Math.Atan2(gamePadStateEventArgs.GamePadState.ThumbSticks.Right.Y, gamePadStateEventArgs.GamePadState.ThumbSticks.Right.X)) * -1; // Todo: Why do have to invert? var rotationDifference = (float)Math.Atan2(Math.Sin(targetRotation - originalRotation), Math.Cos(targetRotation - originalRotation)); this.Player.Weapon.Rotation += rotationDifference * 0.05f; this.player.Weapon.FireWeapon(); }