Esempio n. 1
0
        protected override void Initialize()
        {
            base.Initialize();

            //The SprayEmitter emits Particles in a fountain-like manner. You can adjust the
            //angle of the spray, and also the spread. The SprayEmitter constructor takes
            //both of its angle arguments in radians.
            spray = new SprayEmitter(1000, MathHelper.ToRadians(-90f), MathHelper.ToRadians(30f));
            spray.Position = new Vector2(400f, 550f);
            spray.ParticleSpeed = 250f;
            spray.ParticleSpeedRange = 100f;
            spray.DischargeQuantity = 3;
            spray.ParticleColor = Color.Red;

            //The CircleEmitter emits Particles from a random position inside a circle. It
            //can also emit Particles only from the circles edge, like a ring shape. You can
            //set the spawned Particles to face away from the circles center, or in a
            //random direction.
            circle = new CircleEmitter(1000, 50f, false, CircleEmitter.RadialSpread.FromCenter);
            circle.Position = new Vector2(150f, 350f);
            circle.ParticleSpeed = 100f;
            circle.DischargeQuantity = 3;
            circle.ParticleColor = Color.Blue;

            //The SpiralEmitter can emit Particles in a spiral shape. You can adjust the
            //number of segments in the spiral, and also the direction of the spiral.
            //In this example, we have set the DischargeQuantity to be the same as spiral
            //segments, so at each trigger we will get 1 complete ring.
            spiral = new SpiralEmitter(1000, 150f, 32, SpiralEmitter.SpiralDirection.Clockwise);
            spiral.Position = new Vector2(650f, 350f);
            spiral.ParticleSpeed = -100f;
            spiral.DischargeQuantity = 32;
            spiral.ParticleColor = Color.Green;

            //The LineEmitter spawns Particles from a random position along a line. You can
            //change the length, and rotation of the line. It could be useful for creating
            //rain or snow effects.
            line = new LineEmitter(1000, 800f);
            line.Position = new Vector2(400f, 0f);
            line.ParticleSpeed = 150f;
            line.DischargeQuantity = 3;

            //The TimeTriggerController Modifier causes the Emitter to trigger at the
            //specified interval.
            //Unfortunately there is a bug in this Modifier which causes it to only
            //affect 1 Emitter at a time. It will be fixed in next version.
            spray.ApplyModifier(new TimedTriggerController(50f));
            circle.ApplyModifier(new TimedTriggerController(50f));
            spiral.ApplyModifier(new TimedTriggerController(250f));
            line.ApplyModifier(new TimedTriggerController(50f));

            //And of course, we need to add the Emitters to the ParticleSystem.
            system.AddEmitter(spray);
            system.AddEmitter(circle);
            system.AddEmitter(spiral);
            system.AddEmitter(line);
        }
Esempio n. 2
0
        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            _content = new ContentManager(Services);

            _graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;
            _graphics.PreferMultiSampling = false;
            //_graphics.PreferredBackBufferFormat = SurfaceFormat.Bgr565;
            _graphics.ApplyChanges();
            //_graphics.ToggleFullScreen();

            _system = new ParticleSystem(this);

            _snow = new LineEmitter(_system, 1000, 800f, 0f);
            _snow.Position = new Vector2(400f, 0f);
            _snow.ParticleLifespan = 15000;
            _snow.ParticleSpeed = 50f;
            _snow.ParticleSpeedRange = 50f;
            _snow.ParticleColor = Color.Azure;
            _snow.ParticleScale = .25f;
            _snow.ApplyModifier(new SineForceModifier(10f, 20f));
            _snow.ApplyModifier(new RandomScaleModifier(.05f, .2f));
            _snow.ApplyController(new TimedTriggerController(10));
            _snow.ApplyModifier(new OpacityModifier(1f, 0f));

            _fireworks = new SprayEmitter(_system, 500, MathHelper.Pi, MathHelper.PiOver4);
            _fireworks.Position = new Vector2(400f, 600f);
            _fireworks.ParticleSpeed = 500f;
            _fireworks.ParticleSpeedRange = 100f;
            _fireworks.ParticleColor = Color.BurlyWood;
            _fireworks.ParticleLifespan = 2000;
            _fireworks.ParticleScale = .5f;
            _fireworks.ParticleOpacity = .25f;
            _fireworks.ApplyModifier(new GravityModifier(0f, 250f));
            _fireworks.ApplyController(new TimedTriggerController(40));

            _trail = new Emitter(_system, 5000);
            _trail.ParticleLifespan = 250;
            _trail.ParticleSpeed = 25f;
            _trail.ApplyModifier(new ColorModifier(Color.Goldenrod, Color.Honeydew));
            _trail.ApplyModifier(new ScaleModifier(.2f, 0f));
            _trail.ApplyController(new TrailController(_fireworks, 10));

            _explosion = new Emitter(_system, 5000);
            _explosion.DischargeQuantity = 250;
            _explosion.ParticleScale = .5f;
            _explosion.ParticleSpeed = 155f;
            _explosion.ParticleSpeedRange = 300f;
            _explosion.ApplyModifier(new ColorModifier(Color.PowderBlue, Color.Red));
            _explosion.ApplyModifier(new OpacityModifier(1f, 0f));
            _explosion.ApplyModifier(new AtmosphereModifier(0.2f));
            _explosion.ApplyController(new ExplosionController(_fireworks));
        }
Esempio n. 3
0
        protected override void Initialize()
        {
            //Creating the EmitterGroup, it must be given a name.
            group = new EmitterGroup("test");

            //Create two simple spray emitters.
            emitter1 = new SprayEmitter(1000, -MathHelper.PiOver2, MathHelper.Pi);
            emitter1.ParticleSpeed = 100f;
            emitter1.ParticleColor = Color.SteelBlue;
            emitter1.Position.Y = -50f;

            emitter2 = new SprayEmitter(1000, MathHelper.PiOver2, MathHelper.Pi);
            emitter2.ParticleSpeed = 100f;
            emitter2.ParticleColor = Color.Tomato;
            emitter2.Position.Y = 50f;

            //We add the Emitters to the EmitterGroup (instead of adding them to the
            //ParticleSystem).
            group.AddEmitter(emitter1);
            group.AddEmitter(emitter2);

            //Now we can apply Modifiers to the EmitterGroup. Notice that there is a
            //seperate Modifier for GroupMouseController. As the position of Emitters is
            //relative to the position of the EmitterGroup, applying a regalar
            //EmitterMouseController would result in undesired results... This modifier
            //adjusts the position of the EmitterGroup, and not the Emitters.
            group.ApplyModifier(new RandomScaleModifier(.1f, 1f));
            group.ApplyModifier(new GroupMouseController(true));

            //Finally we add the EmitterGroup to the ParticleSystem.
            system.AddEmitterGroup(group);

            //Of course you can choose to ignore EmitterGroups, and add Emitters to the
            //ParticleSystem directly instead. However you should take care to never
            //add an Emitter to more than one container.

            base.Initialize();
        }