示例#1
0
        private void completeLine(Vector2 position, Boolean ultimo)
        {
            if (lastPosition != null)
            {
                float distance        = BringelUtils.Distance(position, lastPosition);
                int   particlesNumber = (int)Math.Round(distance / 3);

                if (distance <= 500)
                {
                    for (int i = 1; i < particlesNumber + 1; i++)
                    {
                        if ((position.Y < idealPosition) && ultimo)
                        {
                            Console.WriteLine("oi");
                            break;
                        }

                        float posX = MathHelper.Lerp(position.X, lastPosition.X, (float)i / (particlesNumber));
                        float posY = MathHelper.Lerp(position.Y, lastPosition.Y, (float)i / (particlesNumber));

                        createParticle(new Vector2(posX, posY));
                    }
                }
            }
        }
示例#2
0
        public static void Update(GameTime gameTime)
        {
            for (int i = 0; i < fireParticles.Count; i++)
            {
                fireParticles[i].Update(gameTime);

                float posSoma    = 0;
                float numSomados = 0;
                float posMedia   = 0;

                for (int o = 0; o < fireParticles.Count; o++)
                {
                    if (BringelUtils.Distance(new Vector2(fireParticles[i].x, fireParticles[i].y), new Vector2(fireParticles[o].x, fireParticles[o].y)) < 60)
                    {
                        if (fireParticles[o].y < fireParticles[i].y - 20)
                        {
                            posSoma += fireParticles[o].x;
                            numSomados++;
                        }
                    }
                }



                if (numSomados > 0)
                {
                    posMedia           = posSoma / numSomados;
                    fireParticles[i].x = MathHelper.Lerp(fireParticles[i].x, posMedia, 0.05f);
                }



                if (fireParticles[i].alpha < 0.12f)
                {
                    fireParticles.Remove(fireParticles[i]);
                }
            }
        }