-- Define our particle characteristics
pAge = Allocate(1) ; -- Allocate a TReal age member
pSpin = Allocate(1); -- Allocate a TReal spin member
pOriginalRadius = Allocate(1); -- Allocate a TReal radius member
pRadius = Allocate(1); -- Allocate a TReal radius member
pSpinSpeed = Allocate(1); -- Allocate a TReal spin member
pAngleX = Allocate(1);
pAngleY = Allocate(1);
pX = Allocate(1);
pY = Allocate(1);
pOriginalX = Allocate(1);
pOriginalY = Allocate(1);

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

SetNumParticles(10);    -- Create some particles
pOriginalRadius:Init( 150 ); -- rayon en pixel
pRadius:Init( pOriginalRadius ); -- rayon en pixel
pColor:Init( Color(1,1,1,1) );
pScale:Init( 1 );
pAge:Init(0);
pAngleX:Init(f2dRotation(fAngleCircle(1,10))[1]);
pAngleY:Init(f2dRotation(fAngleCircle(1,10))[2]);

pOriginalX:Init(pAngleX*pRadius + dLocus[1]);
pOriginalY:Init(pAngleY*pRadius + dLocus[2]);

pX:Init(pOriginalX);
pY:Init(pOriginalY);
pPosition:Init(Vec2(pOriginalX,pOriginalY));  -- position around dlocus

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


--pPosition:Anim(pPosition); -- f2dRotation(NextAngle(nb part));
 
pRadius:Anim(fClosedCycle(0,200,900) + pOriginalRadius);

pX:Anim(  dLocus[1] + (pRadius * pAngleX) );
pY:Anim(  dLocus[2] + (pRadius * pAngleY) );

pPosition:Anim(Vec2(pX,pY));


--pScale:Anim( fClosedCycle(0,3,900) );
pColor:Anim( pColor );
pSpin:Anim( pSpin + fTimeScale(pSpinSpeed)  );




--pUp:Anim(  f2dRotation( pSpin )  ); --fClosedCycle(5,0,900) + 
-- Add time to the age
pAge:Anim( pAge+fAge() );

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

-- Create an initial particle
CreateParticles( 10 );

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

