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

SetNumParticles(40);    -- Create some particles

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

--pPosition:Init( fPick( Vec2(100,0.2), Vec2(200,0) ) + dLocus );
--pPosition:Init(fRange(Vec2(0,0), Vec2(1024,0))+dLocus);
pPosition:Init(fRange(Vec2(-15,-15), Vec2(15,15))+dLocus);
pVelocity:Init( fRange( Vec2(0,0), Vec2(0,0) ) );
colorB = fRange(70,255)/255;
pColor:Init( Color(1,1,colorB,1) );
pScale:Init( fRange(0.1, 1.1) );
pAge:Init(0);
pSpin:Init( fRange( 0, 2*3.1415927 ) );
pSpinSpeed:Init( fRange(-1,1)*18 );

pPosition:Anim( pPosition + fTimeScale(pVelocity) );
--pPosition:Anim( pPosition );
pScale:Anim( fFade(pAge,pScale,3000,0) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,600)) );

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,500) ) );

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

