Time for action – handling user input
Add the
FireShot()
helper method to thePlayerManager
class:Private Sub FireShot() If shotTimer >= minShotTimer Then PlayerShotManager.FireShot( playerSprite.Location + gunOffset, New Vector2(0, -1), True) shotTimer = 0.0 End If End Sub
Add the
HandleKeyboardInput()
helper method to thePlayerManager
class:Private Sub HandleKeyboardInput(keyState As KeyboardState) If keyState.IsKeyDown(Keys.Up) Then playerSprite.Velocity += new Vector2(0, -1) End If If keyState.IsKeyDown(Keys.Down) Then playerSprite.Velocity += new Vector2(0, 1) End If If keyState.IsKeyDown(Keys.Left) Then playerSprite.Velocity += new Vector2(-1, 0) End If If keyState.IsKeyDown(Keys.Right) Then playerSprite.Velocity += new Vector2(1, 0) End If If keyState.IsKeyDown(Keys.Space) Then FireShot() End If End Sub
Add the
HandleGamepadInput()
helper...