-- Allocate Initial Variables
pAge = Allocate( 1 );
pSpin = Allocate( 1 );
pSpinSpeed = Allocate( 1 );
pVelocity = Allocate( 2 );

-- Set Texture/BlendMode
SetTexture( "particles/mouse" );
SetBlendMode( kBlendNormal );

-- Max Particle Count
SetNumParticles( 600 );

dVelocity = 25;
dVelocityDown = Vec2( 0, 200 );
dSize = 1.25;
dMaxAge = 1000;

if not dLocus then
   dLocus = Vec2( 300, 300 );
end

-- Initial Values
pColor:Init( Color( 1, 1, 1, 1 ) );
pAge:Init( 0 );
pSpin:Init( fRange( -2 * 3.1415927, 2 * 3.1415927 ) );
pSpinSpeed:Init( fRange( -1, 1 ) );
pPosition:Init( fRange( dLocus - dSize, dLocus + dSize ) );
pScale:Init( fRange( 0.25, 0.75 ) );
pVelocity:Init( Vec2( fRange( -dVelocity, dVelocity ), fRange( -dVelocity, dVelocity ) ) );

-- Animated Values
pSpin:Anim( pSpin + pSpinSpeed );
pUp:Anim( f2dRotation( pSpin ) );
pColor:Anim( fFade( pAge, Color( 1, 1, 1, 1 ), dMaxAge, Color( 1, 1, 1, 0 ) ) );
pVelocity:Anim( pVelocity + fTimeScale( dVelocityDown ) );
pPosition:Anim( pPosition + fTimeScale( pVelocity ) );

-- Increment Age
pAge:Anim( pAge + fAge() );

Anim( fExpire( fGreater( pAge, dMaxAge ) ) );

-- Only fire if gActive is true
gActive = 0;

function Update( seconds )
    if gActive > 0 then
		CreateParticles( 0.25 );
    end
end