-- Define our particle characteristics
pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member
pSpin = Allocate(1); -- Allocate a TReal spin member
pSpinSpeed = Allocate(1); -- Allocate a TReal spin member

-- Set the particle texture
SetTexture("dust");
SetBlendMode(kBlendNormal);

SetNumParticles(500);    -- Create some particles

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

pPosition:Init(fRange(Vec2(0,0), Vec2(100,50))+dLocus);
pVelocity:Init( fRange( Vec2(-30,30), Vec2(-30,30) ) );
pColor:Init( Color(1,1,1,1) );
pScale:Init( 1.0 );
pAge:Init(0);
pSpin:Init( fRange( 0, 2*3.1415927 ) );
pSpinSpeed:Init( fRange( -0, 0 ) );

pPosition:Anim( pPosition + fTimeScale(pVelocity) );
pPosition:Anim( pPosition );
pScale:Anim( pScale + fTimeScale(0) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,0)) );
pColor:Anim( fFade( pAge,Color(1,1,0,0.2), 100, Color(1,1,0,0.3), 1000, Color(1,1,0,0.1) ) );
pSpin:Anim( pSpin + fTimeScale( pSpinSpeed ) );
pUp:Anim( f2dRotation( pSpin ) );
-- Add time to the age
pAge:Anim( pAge+fAge() );

-- Expire particles over 1500 ms old
Anim( fExpire( fGreater(pAge, 3000) ) );

-- Create an initial particle
CreateParticles( 1 );

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   -- Create 10 particles per second
   CreateParticles( seconds * 10 );
end

