public void AddExplosion(Vector2 explosionPos, int numberOfParticles, float size, float maxAge, GameTime gameTime) { for (var i = 0; i < numberOfParticles; i++) { var particle = new ParticleData(explosionPos, size, maxAge, i, gameTime); ParticleList.Add(particle); } }
private Boolean UpdateParticle(GameTime gameTime, ParticleData particle) { var now = (float)gameTime.TotalGameTime.TotalMilliseconds; var timeAlive = now - particle.BirthTime; if (timeAlive > particle.MaxAge) { return(false); } var relAge = timeAlive / particle.MaxAge; particle.Position = 0.5f * particle.Accelaration * relAge * relAge + particle.Direction * relAge + particle.OrginalPosition; var invAge = 1.0f - relAge; particle.ModColor = new Color(new Vector4(invAge, invAge, invAge, invAge)); var positionFromCenter = particle.Position - particle.OrginalPosition; var distance = positionFromCenter.Length(); particle.Scaling = (50.0f + distance) / 200.0f; return(true); }