Time for action – beginning the WeaponManager module
Add a new module called
WeaponManager
to the Robot Rampage project.Add declarations to the
WeaponManager
module:#Region "Declarations" Public WeaponSpeed As Single = 600 Private _shots As List(Of Particle) = new List(Of Particle) Private _shotRectangle As Rectangle = New Rectangle(0, 128, 32, 32) Private _shotTimer As Single = 0 Private _shotMinTimer As Single = 0.15 #End Region
Add properties to the
WeaponManager
module:#Region "Properties" Public Property Texture As Texture2D Public ReadOnly Property WeaponFireDelay As Single Get Return _shotMinTimer End Get End Property Public ReadOnly Property CanFireWeapon As Boolean Get Return (_shotTimer >= WeaponFireDelay) End Get End Property #End Region
Add the
AddShot()
method to theWeaponManager
module:#Region "Shot Management Methods" Private Sub AddShot( Location As Vector2, Velocity As Vector2, Frame As Integer) Dim shot As Particle...