Esempio n. 1
0
        public FireEmitter(Texture2D tex, Rectangle charPosition, float scale)
        {
            particleTexture = tex;
            particleSourceRect = new Rectangle(0, 0, particleTexture.Width, particleTexture.Height);
            rand = new Random();
            this.scale = scale;

            spawnRate = 10;
            firstAliveIndex = 0;
            firstDeadIndex = 0;
            particles = new List<Particle>();
            for (int i = 0; i < TOTALPARTICLES; i++)
            {
                Particle p = new Particle();
                Reset(p, charPosition, this.scale, this.startColor, this.endColor);
                particles.Add(p);
            }
        }
Esempio n. 2
0
        public void Reset(Particle p, Rectangle charPosition, float scale, Color start, Color end)
        {
            x = (float)rand.NextDouble() * 10 + charPosition.X + charPosition.Width / 2 - 4;
            y = (float)rand.NextDouble() * 10 + charPosition.Y + charPosition.Height / 2 - 3;
            rotationSpeed = (float)rand.NextDouble() * .1f - .05f;
            float startRoation = (float)rand.NextDouble() * MathHelper.TwoPi;

            Vector2 vel = new Vector2(
                (float)rand.NextDouble() * 1.0f - 1.5f,//2.5f,
                (float)rand.NextDouble() * -2.0f);

            p.Alive = false;
            p.Position = new Vector2(x, y);
            p.Velocity = vel;
            p.Rotation = startRoation;
            p.RotationSpeed = rotationSpeed;
            p.Lifetime = 0.2f;
            p.Age = 0;
            p.StartColor = start;
            p.EndColor = end;
            p.CurrentColor = p.StartColor;
            p.Scale = scale;
        }
Esempio n. 3
0
 public void Reset(Particle p, Rectangle charPosition)
 {
     Reset(p, charPosition, 1f, new Color(1.0f, 0.5f, 0.0f, .1f), new Color(1.0f, 0, 0, 0.3f));
 }