Ejemplo n.º 1
0
            public void Update(float frameTime)
            {
                Age += frameTime;
                if (Age >= Lifetime)
                {
                    Alive = false;
                }
                Velocity           += Acceleration * frameTime;
                RadialVelocity     += RadialAcceleration * frameTime;
                TangentialVelocity += TangentialAcceleration * frameTime;

                //Calculate delta p due to radial velocity
                var positionRelativeToEmitter = Position - EmitterPosition;
                var deltaRadial   = RadialVelocity * frameTime;
                var deltaPosition = positionRelativeToEmitter * (deltaRadial / positionRelativeToEmitter.Length);

                //Calculate delta p due to tangential velocity
                var radius = positionRelativeToEmitter.Length;

                if (radius > 0)
                {
                    var theta = MathUtility.ATan(positionRelativeToEmitter.Y, positionRelativeToEmitter.X);
                    theta         += TangentialVelocity * frameTime;
                    deltaPosition += new Vector2D(radius * MathUtility.Cos(theta), radius * MathUtility.Sin(theta))
                                     - positionRelativeToEmitter;
                }
                //Calculate delta p due to Velocity
                deltaPosition += Velocity * frameTime;
                Position      += deltaPosition;
                Spin          += SpinVelocity * frameTime;
                Size          += SizeDelta * frameTime;
                Color         += ColorDelta * frameTime;
            }