Time for action – handling user input
Add the
FireShot()
helper method to the PlayerManager class:private void FireShot() { if (shotTimer >= minShotTimer) { PlayerShotManager.FireShot( playerSprite.Location + gunOffset, new Vector2(0, -1), true); shotTimer = 0.0f; } }
Add the
HandleKeyboardInput()
helper method to the PlayerManager class:private void HandleKeyboardInput(KeyboardState keyState) { if (keyState.IsKeyDown(Keys.Up)) { playerSprite.Velocity += new Vector2(0, -1); } if (keyState.IsKeyDown(Keys.Down)) { playerSprite.Velocity += new Vector2(0, 1); } if (keyState.IsKeyDown(Keys.Left)) { playerSprite.Velocity += new Vector2(-1, 0); } if (keyState.IsKeyDown(Keys.Right)) { playerSprite.Velocity += new Vector2(1, 0); } if (keyState.IsKeyDown(Keys.Space)) { FireShot(); } }
Add the
HandleGamepadInput()
helper method to the...