Time for action – creating the Enemy class
Add a new class called
Enemy
to the Asteroid Belt Assault project.Add declarations to the
Enemy
class:Public EnemySprite As Sprite Public gunOffset As Vector2 = new Vector2(25, 25) Private waypoints As Queue(Of Vector2) = New Queue(Of Vector2)() Private currentWaypoint As Vector2 = Vector2.Zero Private speed As Single = 120 Public Destroyed As Boolean = False Private enemyRadius As Integer = 15 Private previousLocation As Vector2 = Vector2.Zero
Add a constructor to the
Enemy
class:Public Sub New( Texture As Texture2D, Location As Vector2, initialFrame As Rectangle, frameCount As Integer) EnemySprite = new Sprite( location, texture, initialFrame, Vector2.Zero) For x As Integer = 1 to frameCount - 1 EnemySprite.AddFrame( new Rectangle( initialFrame.X + (initialFrame.Width * x), initialFrame.Y, initialFrame.Width, initialFrame...