Time for action – constructing the Particle class
Add a new class called
Particle
to the Asteroid Belt Assault project.Modify the declaration of the class by adding the following line below
Public Class Particle
:Inherits Sprite
Add declarations to represent the additional members of the
Particle
class (beyond those of theSprite
class):Private _acceleration As Vector2 Private _maxSpeed As Single Private initialDuration As Integer Private remainingDuration As Integer Private _initialColor As Color Private _finalColor As Color
Add properties to access the information about the underlying members:
Public ReadOnly Property ElapsedDuration As Integer Get Return initialDuration - remainingDuration End Get End Property Public ReadOnly Property DurationProgress As Single Get Return CSng(ElapsedDuration)/CSng(initialDuration) End Get End Property Public ReadOnly Property IsActive As Boolean Get Return remainingDuration > 0 End Get End Property
Add...