/// <summary> /// A protected method to return a new particle pixel with the randomized color attributes. /// </summary> /// <returns>A new particle pixel with the new color values.</returns> protected override SdlDotNet.Particles.BaseParticle CreateParticle() { ParticlePixel p = new ParticlePixel(); p.Color = Color.FromArgb( Random.Next(m_MinR, m_MaxR), Random.Next(m_MinG, m_MaxG), Random.Next(m_MinB, m_MaxB)); return(p); }
/// <summary> /// Run the application /// </summary> public void Go() { // Make the particle emitter. emit = new ParticleRectangleEmitter(particles); emit.Frequency = 50000; // 100000 every 1000 updates. emit.LifeFullMin = 20; emit.LifeFullMax = 50; emit.LifeMin = 10; emit.LifeMax = 30; emit.DirectionMin = -2; // shoot up in radians. emit.DirectionMax = -1; emit.ColorMin = Color.DarkBlue; emit.ColorMax = Color.LightBlue; emit.SpeedMin = 5; emit.SpeedMax = 20; emit.MaxSize = new SizeF(5, 5); emit.MinSize = new SizeF(1, 1); // Make the first particle (a pixel) ParticlePixel first = new ParticlePixel(Color.White, 100, 200, new Vector(0, 0, 0), -1); particles.Add(first); // Add it to the system if (File.Exists(Path.Combine(dataDirectory, "marble1.png"))) { filePath = ""; } // Make the second particle (an animated sprite) AnimationCollection anim = new AnimationCollection(); SurfaceCollection surfaces = new SurfaceCollection(); surfaces.Add(Path.Combine(filePath, Path.Combine(dataDirectory, "marble1.png")), new Size(50, 50)); anim.Add(surfaces, 1); AnimatedSprite marble = new AnimatedSprite(anim); marble.Animate = true; ParticleSprite second = new ParticleSprite(marble, 200, 200, new Vector(-7, -9, 0), 500); second.Life = -1; particles.Add(second); // Add it to the system // Add some manipulators to the particle system. ParticleGravity grav = new ParticleGravity(0.5f); particles.Manipulators.Add(grav); // Gravity of 0.5f particles.Manipulators.Add(new ParticleFriction(0.1f)); // Slow down particles particles.Manipulators.Add(vort); // A particle vortex fixed on the mouse particles.Manipulators.Add(new ParticleBoundary(SdlDotNet.Graphics.Video.Screen.Size)); // fix particles on screen. Events.Run(); }