-- 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("empty.png");
SetBlendMode(kBlendNormal);

SetNumParticles(20);    -- Create some particles

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

pPosition:Init( fPick( Vec2(0,0), Vec2(0,0) ) + dLocus );
pVelocity:Init( fRange( Vec2(0,0), Vec2(0,0) ) );
pScale:Init( 0 );
pAge:Init(0);
pSpin:Init( fRange( 0, 0 ) );
pSpinSpeed:Init( fRange(0,0) );

pPosition:Anim( pPosition + fTimeScale(pVelocity) );
--pPosition:Anim( pPosition );
--pScale:Anim( pScale + fTimeScale(1) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,0)) );
pColor:Anim( fFade( pAge,   Color(40/255,255/255,55/255,0), 220, 
                        Color(40/255,255/255,55/255,0)));

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,fRange(1100,1500)) ) );

-- 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 * 0 );
end

