Example #1
0
        public override Vector2 GetSpeed(Emitter emitter, Particle particle)
        {
            //Get direction
            Vector2 direction = new Vector2(emitter.Position.X - particle.Position.X, emitter.Position.Y - particle.Position.Y);
            //Calculate speed
            float speed = MathHelper.Lerp(minSpeed, maxSpeed, (float)random.NextDouble());

            //Calculate final vector
            return direction / direction.Length() * speed;
        }
Example #2
0
        /// <summary>
        /// Spawn a single batch of particles. (if paused == false then Shoot is called every Update)
        /// </summary>
        public void Shoot()
        {
            waitList += particlesPerLoop; //Add new particles to waitlist

            //Spawn particles and empty waitlist
            int spawnQue = (int)waitList;
            waitList -= spawnQue;
            for (int i = 0; i < spawnQue; i++)
            {
                //Spawn a particle
                Particle newParticle = new Particle(ttl, new Vector2(MathHelper.Lerp(previousPosition.X, position.X, (float)GameManager.Random.NextDouble()), MathHelper.Lerp(previousPosition.Y, position.Y, (float)GameManager.Random.NextDouble())) + spawnShape.GetPosition(), beginSize, endSize, beginColor, endColor, texture, modifiers);
                //Set particle speed
                newParticle.SetSpeed(spawnSpeed.GetSpeed(this, newParticle));

                //Add particle to list
                particles.Add(newParticle);
            }
        }
Example #3
0
 public override Vector2 GetSpeed(Emitter emitter, Particle particle)
 {
     return new Vector2(MathHelper.Lerp(minSpeed.X, maxSpeed.X, (float)random.NextDouble()), MathHelper.Lerp(minSpeed.Y, maxSpeed.Y, (float)random.NextDouble()));
 }
Example #4
0
 public abstract Vector2 GetSpeed(Emitter emitter, Particle particle);
 public override void Update(Particle particle)
 {
     particle.Speed += new Vector2((maxSpeed.X - minSpeed.X) * (float)GameManager.Random.NextDouble() + minSpeed.X, (maxSpeed.Y - minSpeed.Y) * (float)GameManager.Random.NextDouble() + minSpeed.Y);
 }
 public abstract void Update(Particle particle);
 public override void Update(Particle particle)
 {
     particle.Speed += gravity;
 }