-- 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("heart2");
SetBlendMode(kBlendNormal);

SetNumParticles(50);    -- Create some particles

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

pPosition:Init( fRange( Vec2(-50,0), Vec2(50,0) ) + dLocus );
pVelocity:Init( fRange( Vec2(-10,-120), Vec2(10,-60) ) );
pColor:Init( Color(1,1,1,1) );
pScale:Init( 0.5 );
pAge:Init(0);

pPosition:Anim( pPosition + fTimeScale(pVelocity) );
pPosition:Anim( pPosition );
pScale:Anim( pScale + fTimeScale(1) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,-250)) );
pColor:Anim( fFade( pAge,Color(1,1,1,1), 300, Color(1,0,0,1), 500, Color(1,0,0,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,1000) ) );

-- Create an initial particle
--CreateParticles( 1 );

gElapsed = 0;
gActive = true;

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
	if gActive then
		gElapsed =  gElapsed + seconds;
		if(gElapsed > 2.5) then
			CreateParticles( seconds * 15 );
		else
		   -- Create 10 particles per second
		   CreateParticles( seconds * 5 );
		end
		
		--DebugOut("*** Hearts elapsed = "..gElapsed);
	end
end

