コード例 #1
0
ファイル: WindParticle.cs プロジェクト: TobieD/Glide
        protected override void InitializeParticle(Particle p, Vector2 where)
        {
            base.InitializeParticle(p, where);

            // the base is mostly good, but we want to simulate a little bit of wind
            // heading to the right.
            p.Acceleration.X += MathHelp.RandomBetween(10, 50);
        }
コード例 #2
0
ファイル: ParticleSystem.cs プロジェクト: TobieD/Glide
        protected virtual void InitializeParticle(Particle p, Vector2 where)
        {
            // first, call PickRandomDirection to figure out which way the particle
            // will be moving. velocity and acceleration's values will come from this.
            Vector2 direction = new Vector2(1,-1);

            // pick some random values for our particle
            float velocity =
                MathHelp.RandomBetween(minInitialSpeed, maxInitialSpeed);
            float acceleration =
                MathHelp.RandomBetween(minAcceleration, maxAcceleration);
            float lifetime =
                MathHelp.RandomBetween(minLifetime, maxLifetime);
            float scale =
                MathHelp.RandomBetween(minScale, maxScale);
            float rotationSpeed =
                MathHelp.RandomBetween(minRotationSpeed, maxRotationSpeed);

            // then initialize it with those random values. initialize will save those,
            // and make sure it is marked as active.
            p.Initialize(
                where, velocity * direction, acceleration * direction,
                lifetime, scale, rotationSpeed);
        }
コード例 #3
0
ファイル: ParticleSystem.cs プロジェクト: TobieD/Glide
        public override void Initialize()
        {
            InitializeConstants();

            // calculate the total number of particles we will ever need, using the
            // max number of effects and the max number of particles per effect.
            // once these particles are allocated, they will be reused, so that
            // we don't put any pressure on the garbage collector.
            m_Particles = new Particle[m_NrParticles * maxNumParticles];
            m_FreeParticles = new Queue<Particle>(m_NrParticles * maxNumParticles);
            for (int i = 0; i < m_Particles.Length; i++)
            {
                m_Particles[i] = new Particle();
                m_FreeParticles.Enqueue(m_Particles[i]);
            }
            base.Initialize();
        }