//Particle p; public Game() { win = new RenderWindow(new SFML.Window.VideoMode(800, 600), "Particles ^^"); win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); }; gTime = new GameTime(); //p = new Particle(new SFML.Window.Vector2f(100, -3)); pH = new ParticleHandler(); }
public void Update(GameTime t) { lifeTime += (float)t.Ellapsed.TotalMilliseconds; s.Position += new Vector2f((float)Math.Sin(lifeTime * 0.003) / 40 * size, size/10) * (float)t.Ellapsed.TotalMilliseconds; if (s.Position.Y > 1000) IsAlive = false; }
public void Update(GameTime t) { count += (float)t.Ellapsed.TotalMilliseconds; //SpawnParticles(100); if (count > 10) { particles.Add(new Particle(new Vector2f(800 * (float)r.NextDouble(), -r.Next(10)))); count = 0; } for(int i = 0; i<particles.Count; i++) { if (!particles[i].IsAlive) { particles.RemoveAt(i); i--; continue; } particles[i].Update(t); } }