Time for action – finishing the Particle class
We will now finish the Particle
class we just created by performing the following steps:
1. Add the
Activate()
method to theParticle
class as follows:#region Particle Activation public void Activate( Vector3 position, Vector3 velocity, float duration, float scale) { this.duration = duration; initialDuration = duration; this.position = position; this.velocity = velocity; this.scale = scale; } #endregion
2. Add the
Update()
method to theParticle
class as follows:#region Update public void Update(GameTime gameTime) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; duration -= elapsed; velocity += (Gravity * elapsed); position += (velocity * elapsed); } #endregion
3. Add the
Draw()
method to theParticle
class as follows:#region Draw public void Draw(ArcBallCamera camera, Effect effect) { Matrix billboard = Matrix.CreateBillboard( position, camera...