Time for action – creating the PlayerManager class
Add a new class called
PlayerManager
to the Asteroid Belt Assault project.Add declarations to the
PlayerManager
class:Public playerSprite As Sprite Private playerSpeed As Single = 160.0 Private playerAreaLimit As Rectangle Public PlayerScore As Long = 0 Public LivesRemaining As Integer = 3 Public Destroyed As Boolean = false Private gunOffset As Vector2 = new Vector2(25, 10) Private shotTimer As Single = 0.0 Private minShotTimer As Single = 0.2 Private playerRadius As Integer = 15 Public PlayerShotManager As ShotManager
Add a constructor to the
PlayerManager
class:Public Sub New ( Texture As Texture2D, initialFrame As Rectangle, frameCount As Integer, screenBounds As Rectangle) playerSprite = new Sprite( new Vector2(500, 500), texture, initialFrame, Vector2.Zero) PlayerShotManager = new ShotManager( texture, new Rectangle(0, 300, 5, 5), 4, 2, ...