コード例 #1
0
ファイル: ParticleEngine.cs プロジェクト: melari/monopole
        /* =========================================================
         * Below are helper functions to create
         * predetermined particle patterns (ie fire, smoke, ect.)
         * ======================================================= */
        public void CreateFire(Vector2 position, Color color, float scale = 0.25f, bool smoke = true)
        {
            Particle p = new SpriteParticle(this, Resources.GetSprite("p_explosion"), position, color);
            p.rotation = (float)(MathExtra.random.NextDouble() * Math.PI * 2);
            p.maxSpeed = 2;
            p.SetLife(150);
            p.scale = scale;
            p.alpha = 0;
            p.methods.Add(new ConstantForceMethod(this, new Vector2((float)MathExtra.random.NextDouble() / 4 - 0.125f, (float)MathExtra.random.NextDouble() / 2f - 1f)));
            p.methods.Add(new FadeInOutMethod(this));
            this.AddParticle(p, true);

            if (smoke)
            {
                p = new SpriteParticle(this, Resources.GetSprite("p_smoke"), position - Vector2.UnitY * 50, Color.White);
                p.rotation = (float)(MathExtra.random.NextDouble() * Math.PI * 2);
                p.maxSpeed = 1.5f;
                p.SetLife(300);
                p.alpha = 0;
                p.methods.Add(new ScaleMethod(this, scale / 2, scale));
                p.methods.Add(new ConstantForceMethod(this, new Vector2((float)MathExtra.random.NextDouble() / 4 - 0.125f, (float)MathExtra.random.NextDouble() / 2f - 1f)));
                p.methods.Add(new FadeInOutMethod(this));
                this.AddParticle(p);
            }
        }
コード例 #2
0
        /* =========================================================
        * Below are helper functions to create
        * predetermined particle patterns (ie fire, smoke, ect.)
        * ======================================================= */
        public void CreateFire(Vector2 position, Color color, float scale = 0.25f, bool smoke = true)
        {
            Particle p = new SpriteParticle(this, Resources.GetSprite("p_explosion"), position, color);

            p.rotation = (float)(MathExtra.random.NextDouble() * Math.PI * 2);
            p.maxSpeed = 2;
            p.SetLife(150);
            p.scale = scale;
            p.alpha = 0;
            p.methods.Add(new ConstantForceMethod(this, new Vector2((float)MathExtra.random.NextDouble() / 4 - 0.125f, (float)MathExtra.random.NextDouble() / 2f - 1f)));
            p.methods.Add(new FadeInOutMethod(this));
            this.AddParticle(p, true);

            if (smoke)
            {
                p          = new SpriteParticle(this, Resources.GetSprite("p_smoke"), position - Vector2.UnitY * 50, Color.White);
                p.rotation = (float)(MathExtra.random.NextDouble() * Math.PI * 2);
                p.maxSpeed = 1.5f;
                p.SetLife(300);
                p.alpha = 0;
                p.methods.Add(new ScaleMethod(this, scale / 2, scale));
                p.methods.Add(new ConstantForceMethod(this, new Vector2((float)MathExtra.random.NextDouble() / 4 - 0.125f, (float)MathExtra.random.NextDouble() / 2f - 1f)));
                p.methods.Add(new FadeInOutMethod(this));
                this.AddParticle(p);
            }
        }
コード例 #3
0
ファイル: TestRoom.cs プロジェクト: melari/Atomic
        public TestRoom(Engine a, int layer)
            : base(a, layer)
        {
            a.console.RegisterStateCommands(this);
            a.console.RegisterStateCommands(pe);
            a.console.Execute("fps true");

            player = new Player(a, new Vector2(100f, 100f));
            objects.Add(player);

            Particle p = new EmitterParticle(pe, new Vector2(a.resolution.X / 4 * 3, a.resolution.Y * 3 / 4 + 50), delegate(Particle emitter, ParticleEngine engine)
            {
                Particle tail = new SpriteParticle(engine, Resources.GetSprite("p_explosion"), emitter.position, Color.Orange);
                tail.rotation = (float)(MathExtra.random.NextDouble() * Math.PI * 2);
                tail.SetLife(150);
                tail.alpha = 0;
                tail.methods.Add(new FadeInOutMethod(engine));
                tail.methods.Add(new ScaleMethod(engine, 0.15f, 0.01f));
                engine.AddParticle(tail, true);
            });
            p.methods.Add(new PointForceMethod(pe, new Vector2(a.resolution.X / 4 * 3 + 50, a.resolution.Y * 3 / 4 + 50), 0.5f));
            p.velocity = new Vector2(0.0f, -10.0f);
            pe.AddParticle(p);
        }