Time for action – building the Enemy class
Add a new class called
Enemy
to the Robot Rampage project.Add declarations to the
Enemy
class:#Region "Declarations" Public EnemyBase As Sprite Public EnemyClaws As Sprite Public EnemySpeed As Single = 60 Public CurrentTargetSquare As Vector2 Public Destroyed As Boolean = False Private _collisionRadius As Integer = 14 #End Region
Add a constructor to the
Enemy
class:#Region "Constructor" Public Sub New( worldLocation As Vector2, texture As Texture2D, initialFrame As Rectangle) EnemyBase = new Sprite( worldLocation, texture, initialFrame, Vector2.Zero) EnemyBase.CollisionRadius = _collisionRadius Dim turretFrame As Rectangle = initialFrame turretFrame.Offset(0, initialFrame.Height) EnemyClaws = new Sprite( worldLocation, texture, turretFrame, Vector2.Zero) End Sub #End Region
Add the
Update()
andDraw()
methods to theEnemy
class:#region "Public Methods...