Time for action – constructing the Particle class
Add a new class called
Particle.cs
to the Asteroid Belt Assault project.Insert the standard
using
directives at the top of the class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Modify the declaration of the class by adding
: Sprite
to the end:class Particle : Sprite
Add declarations to represent the additional members of the Particle class (beyond those of the Sprite class):
private Vector2 acceleration; private float maxSpeed; private int initialDuration; private int remainingDuration; private Color initialColor; private Color finalColor;
Add properties to access the information about the underlying members:
public int ElapsedDuration { get { return initialDuration - remainingDuration; } } public float DurationProgress { get { return (float)ElapsedDuration/ (float)initialDuration; } } public bool IsActive { get { return (remainingDuration > 0)...