예제 #1
0
 public void Render()
 {
     foreach (var particle in LiveParticles)
     {
         ParticleSprite.Color    = ToColor(particle.Color);
         ParticleSprite.Position = particle.Position.Convert();
         ParticleSprite.Rotation = (float)(180f / Math.PI) * particle.Spin;
         ParticleSprite.Scale    = new Vector2f(particle.Size, particle.Size);
         ParticleSprite.Draw();
     }
 }
예제 #2
0
        /// <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();
        }
예제 #3
0
 public void Render()
 {
     //_batch.Clear();
     foreach (var particle in LiveParticles)
     {
         ParticleSprite.Color        = ToColor(particle.Color);
         ParticleSprite.Position     = particle.Position;
         ParticleSprite.Rotation     = MathUtility.Degrees(particle.Spin);
         ParticleSprite.UniformScale = particle.Size;
         //_batch.AddClone(ParticleSprite);
         ParticleSprite.Draw();
     }
     //_batch.Draw();
 }
 public void Render()
 {
     //_batch.Clear();
     foreach (var particle in LiveParticles)
     {
         ParticleSprite.Color    = ToColor(particle.Color);
         ParticleSprite.Position = particle.Position;
         ParticleSprite.Rotation = (float)(180f / Math.PI) * particle.Spin;
         ParticleSprite.Scale    = new Vector2f(particle.Size, particle.Size);
         //_batch.AddClone(ParticleSprite);
         ParticleSprite.Draw();
     }
     //_batch.Draw();
 }