pAge = Allocate(1) ; -- Allocate a parameter representing age.
pCol = Allocate(4);
-- Set the particle texture
SetTexture("star.xml");
SetBlendMode(kBlendAdditiveAlpha);
SetNumParticles(200);    -- Create some particles
if not dPos then
  dPos = Vec2( 0, 0)
end
if not dScale then
   dScale = 2;
end
if not dColor then
   dColor = Color(0.0,0.5,1.0,1);
end

pPosition:Init( f2dRadius( 60 )  * fRange( 0.2, 1 ) * dScale + dPos);
pCol:Init( fPick( dColor, Color( 1,1,1,1) ) );
pScale:Init( fRange( 0.7, 1.2 ) );
pUp:Init( f2dRadius( 1 ) );   -- random radius
pAge:Init( 0 ) ;

-- Fade the particles.

pAge:Anim( pAge+fAge() );
pColor:Anim( fFade( pAge, pCol, 1000, Color(0,0,0,0) ) );
pPosition:Anim( pPosition );
-- Expire particles which faded out completelly.

Anim(  fExpire(  fLess( pColor[ 3 ], 0.001 )  )  ) ;

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
gActive = true;

particles = 25;

function Update(seconds)
   -- Create 20 particle per second
   if gActive then
      CreateParticles( seconds * particles );
   end
end

