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

SetNumParticles(1);    -- Create some particles

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

pPosition:Init((Vec2(0,0))+dLocus);
pScale:Init(0);

pAge:Init(0);
pSpin:Init( fRange( 0, 2*3.1415927 ) );
pSpinSpeed:Init( 6 );

showTime = 600;

pColor:Anim( fFade( pAge,   Color(1,1,1,0), 
                     showTime/3, Color(1,1,1,1), 
                     showTime/3, Color(1,1,1,1), 
                        showTime/3, Color(1,1,1,0)));
pScale:Anim(  fFade( pAge, 0.5, 
                  showTime/3, 1, 
                  showTime/3, 1,   
                  showTime/3, 0.5) );
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,showTime) ) );

-- Create an initial particle
CreateParticles(1);
elapsed = 0;

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   elapsed = elapsed+seconds;
   if elapsed>(showTime+4500)/1000 then
      CreateParticles(1);
      elapsed=0;
   end
end

