Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Add declarations to the ShotManager class:
Public Shots As List(Of Sprite) = New List(Of Sprite)() Private Shared _screenBounds As Rectangle Private Shared _texture As Texture2D Private Shared _initialFrame As Rectangle Private Shared _frameCount As Integer Private Shared _collisionRadius As Integer Private _shotSpeed As Single
Add a constructor to the the ShotManager class:
Public Sub New ( texture As Texture2D, initialFrame As Rectangle, frameCount As Integer, collisionRadius As Integer, shotSpeed As Single, screenBounds As Rectangle) _Texture = texture _InitialFrame = initialFrame _FrameCount = frameCount _CollisionRadius = collisionRadius _shotSpeed = shotSpeed _screenBounds = screenBounds End Sub
ShotManager maintains a list of fired shots. An enemy-fired shot will not hurt enemies, and a player-fired shot will not hurt the player, if they somehow manage to move into one. We will implement these properties, when we build the CollisionManager class, which will check for collisions between fired shots and other game objects by creating two different instances of the ShotManager class.