Time for action – the Particle class
Add a new class file to the Robot Rampage project called
Particle.cs
.Add the following
using
directives to the Particle class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Update the class declaration for the Particle class to derive it from the Sprite class:
class Particle : Sprite
Add declarations to the Particle class:
#region Declarations private Vector2 acceleration; private float maxSpeed; private int initialDuration; private int remainingDuration; private Color initialColor; private Color finalColor; #endregion
Add properties to the Particle class:
#region Properties public int ElapsedDuration { get { return initialDuration - remainingDuration; } } public float DurationProgress { get { return (float)ElapsedDuration / (float)initialDuration; } } public bool IsActive { get { return (remainingDuration > 0); } } #endregion
Add a constructor to the Particle...