/// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultPointSpriteParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above),
            // then you may delete this function all together.
            //-----------------------------------------------------------

            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 2.0f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Emitter.PositionData.Position;

            // Set the Particle's Velocity
            Vector3 sVelocityMin = new Vector3(-50, 50, -50);
            Vector3 sVelocityMax = new Vector3(50, 100, 50);
            cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);

            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Size = cParticle.StartSize = cParticle.EndSize = RandomNumber.Next(10, 50);

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color = cParticle.StartColor = cParticle.EndColor = DPSFHelper.RandomColor();
        }
        protected void UpdateParticleForPosition(DefaultPointSpriteParticle cParticle, float fElapsedTimeInSeconds)
        {
            // Place code to update the Particle here
            // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds;
            cParticle.NormalizedElapsedTime = (cParticle.Position.Y - 20f) / -30f;

            if (cParticle.Position.Y < -10f)
            {
                cParticle.NormalizedElapsedTime = 1.0f;
            }
        }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 //-----------------------------------------------------------
 // TODO: Place your Particle Update functions here, using the
 // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float))
 //-----------------------------------------------------------
 /// <summary>
 /// Example of how to create a Particle Event Function
 /// </summary>
 /// <param name="cParticle">The Particle to update</param>
 /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param>
 protected void UpdateParticleFunctionExample(DefaultPointSpriteParticle cParticle, float fElapsedTimeInSeconds)
 {
     // Place code to update the Particle here
     // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds;
     cParticle.NormalizedElapsedTime = 1.0f;
 }
        private void moveToPosition(DefaultPointSpriteParticle cParticle, Vector2 position)
        {
            Vector2 screenPosition = new Vector2(position.X * ((float)port.Width / 1600f), position.Y * ((float)port.Height / 1200f));

            Vector3 currentScreenPosition = port.Project(cParticle.Position, custprojection, custview, Matrix.Identity);
            currentScreenPosition.X = screenPosition.X;
            currentScreenPosition.Y = screenPosition.Y;
            cParticle.Position = port.Unproject(currentScreenPosition, custprojection, custview, Matrix.Identity);
        }
 protected void UpdateParticleForPosition(DefaultPointSpriteParticle cParticle, float fElapsedTimeInSeconds)
 {
     // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds;
     cParticle.NormalizedElapsedTime = 0.0f;
 }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 //-----------------------------------------------------------
 // TODO: Place your Particle Update functions here, using the
 // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float))
 //-----------------------------------------------------------
 public void UpdateParticlePhysics(DefaultPointSpriteParticle cParticle, float fElapsedTimeInSeconds)
 {
 }
        public void UpdateParticleHitmapCollision(DefaultPointSpriteParticle cParticle, float fElapsedTimeInSeconds)
        {
            if (CustView == null || CustProjection == null) {
                return;
            }

            /* Get SCREEN POSTION */
            Vector3 screenPosition = port.Project(cParticle.Position, custprojection, custview, Matrix.Identity);

            /* Basic culling & physics*/
            if (screenPosition.X < 0 || screenPosition.X > port.Width) {
                if (screenPosition.X < 0) {
                    cParticle.Velocity.X = Math.Abs(cParticle.Velocity.X);
                } else {
                    cParticle.Velocity.X = -Math.Abs(cParticle.Velocity.X);
                }
            }

            if (screenPosition.Y < 0 || screenPosition.Y > port.Height) {
                if (screenPosition.Y > port.Height) {
                    cParticle.NormalizedElapsedTime = 1.0f;
                }
            }

            /* gravity! */
            if (cParticle.Velocity.Y > -9f) {
                cParticle.Velocity.Y -= .02f;
            }

            Vector2 position = new Vector2(screenPosition.X * (1600f / (float)port.Width), screenPosition.Y * (1200f / (float)port.Height));

            if (readPosition(position)) {
                /* HIT! */

                if (position.Y < 150) {
                    cParticle.NormalizedElapsedTime = 1.0f; /* kill the particle */
                    return;
                }

                Vector2 surfacePosition = findSurfacePosition(position, cParticle.Velocity);
                if (position != surfacePosition && cParticle.Velocity.Length() > 2f) {
                    /* move the particle to the surface */
                    position = surfacePosition; //2 * surfacePosition - position;
                    moveToPosition(cParticle, position);
                }

                /* Bounce! */
                if (cParticle.Velocity.Length() > 2f) {
                    Vector3 normal = computeNormal(position);
                    Vector3 inVelocity = cParticle.Velocity;
                    inVelocity.Normalize();
                    Vector3 velocity = Vector3.Reflect(inVelocity, normal);
                    velocity *= cParticle.Velocity.Length() * 0.2f;

                    cParticle.Velocity = velocity;
                    return;
                }

                cParticle.NormalizedElapsedTime = 1.0f; /* kill the particle */

                for (int x = (int)position.X - blockSize; x < (int)position.X + blockSize; x++) {
                    for (int y = (int)position.Y - blockSize; y < (int)position.Y + blockSize; y++) {
                        writePosition(x, y, true);
                    }

                    int lastFill = (int)position.Y - blockSize;
                    for (int y = (int)position.Y + blockSize; y < 1200 && y - ((int)position.Y +blockSize) < 45; y++) {
                        if (readPosition(x, y)) {
                            /* must be continuous fill! */
                            for (int j = y; j > lastFill; j--) {
                                writePosition(x, j, true);
                            }
                            lastFill = y;
                        }
                    }
                }

            }
        }
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultPointSpriteParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above),
            // then you may delete this function all together.
            //-----------------------------------------------------------

            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 20f;

            // Set the Particle's initial Position to be wherever the Emitter is

            Vector3 positionDelta = DPSFHelper.RandomVectorBetweenTwoVectors(InitialProperties.PositionMin, InitialProperties.PositionMax);
            if (positionDelta.Length() > 1f) {
                positionDelta.Normalize();
            }

            cParticle.Position = Emitter.PositionData.Position + positionDelta;

            cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(InitialProperties.VelocityMin, InitialProperties.VelocityMax);

            cParticle.Rotation = DPSFHelper.RandomNumberBetween(InitialProperties.RotationMin, InitialProperties.RotationMax);

            cParticle.RotationalVelocity = DPSFHelper.RandomNumberBetween(InitialProperties.RotationalVelocityMin, InitialProperties.RotationalVelocityMax);

            cParticle.Size = .25f;
            cParticle.StartSize = .25f;
            cParticle.EndSize = 1f;
            cParticle.Color = Color.White;
            cParticle.StartColor = Color.White;
            cParticle.EndColor = Color.White;

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
        }