private static void fireShotsGamePad(GamePadState padState, float elapsed) { if (padState.ThumbSticks.Right != Vector2.Zero) { if (shotTimer >= minShotTimer) { Vector2 angle = padState.ThumbSticks.Right - shipSprite.Position; if (angle != Vector2.Zero) { angle.Normalize(); } shotManager.FireShot(shipSprite.Center, angle, shipSprite.Rotation); SoundEffectManager.GetSound("shipLaser").Play(0.5f, 0f, 0f); shotTimer = 0f; } } shotTimer += elapsed; }
private static void fireShotsMouse(MouseState mouseState, float elapsed) { ButtonState button = (AsteroidsGame.ControlStyle == ControlStyles.KBM_LH) ? mouseState.RightButton : mouseState.LeftButton; if (button == ButtonState.Pressed) { if (shotTimer >= minShotTimer) { Vector2 angle = mouseState.Position.ToVector2() - shipSprite.Position; if (angle != Vector2.Zero) { angle.Normalize(); } shotManager.FireShot(shipSprite.Center, angle, shipSprite.Rotation); SoundEffectManager.GetSound("shipLaser").Play(0.5f, 0f, 0f); shotTimer = 0.0f; } } shotTimer += elapsed; }