#region File Description //----------------------------------------------------------------------------- // Particle.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; #endregion namespace NetRumble { /// /// A single particle in a particle-based effect. /// public class Particle { #region Status Data /// /// The time remaining for this particle. /// public float TimeRemaining; #endregion #region Graphics Data /// /// The position of this particle. /// public Vector2 Position; /// /// The velocity of this particle. /// public Vector2 Velocity; /// /// The acceleration of this particle. /// public Vector2 Acceleration; /// /// The scale applied to this particle. /// public float Scale = 1f; /// /// The rotation applied to this particle. /// public float Rotation; /// /// The opacity of the particle. /// public float Opacity = 1f; #endregion #region Updating Methods /// /// Update the particle. /// /// The amount of elapsed time, in seconds. /// The angular velocity of the particle. /// The change in the scale /// The change in the opacity. public void Update(float elapsedTime, float angularVelocity, float scaleDeltaPerSecond, float opacityDeltaPerSecond) { Velocity.X += Acceleration.X * elapsedTime; Velocity.Y += Acceleration.Y * elapsedTime; Position.X += Velocity.X * elapsedTime; Position.Y += Velocity.Y * elapsedTime; Rotation += angularVelocity * elapsedTime; Scale += scaleDeltaPerSecond * elapsedTime; if (Scale < 0f) { Scale = 0f; } Opacity = MathHelper.Clamp(Opacity + opacityDeltaPerSecond * elapsedTime, 0f, 1f); } #endregion } }