pAge = Allocate(1) ; -- Allocate a TReal age member
pSpinSpeed = Allocate(1); -- Allocate a TReal spin member

-- dLocus is a data source: An external connection to the particle
-- system. Here we define dLocus for FluidFX, since FluidFX doesn't know
-- to provide the data source; in the game it's defined in
-- swarm.cpp as a data source, and it gets the mouse position.
if not dLocus then
   dLocus= Vec2(0,0) ;
end

-- Set the blend mode
SetBlendMode(kBlendNormal);

-- LAST, we set the total number of particles in the particle
-- system. This doesn't 'create' the particles, but rather
-- allocates a block of 'dead' particles that can be created
-- below.
SetNumParticles(400);

-- ------------------------------------------------------------
-- Action Phase

-- Particle Initialization Rules.
--
-- The following rules define how particles are created.
--
-- Any parameter below in initialization or animation rules that
-- is a scalar, Color(), or Vec2() can alternaly take a function
-- that returns the same type--and most functions can take any type
-- and will return that same type. The exception is any function
-- that's expecting a scalar in certain parameter positions.

pPosition:Init( dLocus );

-- Start color (tint) off as white (natural color of image)
pColor:Init( Color(1,1,1,1) );

pScale:Init( 1 );

-- Start age as 0 milliseconds
pAge:Init(0);

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
--
-- The following rules define how particles animate.
-- Each rule is applied on each frame of animation.
pPosition:Anim( pPosition - Vec2( 0, 1));

pScale:Anim( pScale + fTimeScale(1) );
pColor:Anim( fFade( pAge,Color(1,1,1,1), 500, Color(1,1,1,1), 1000, Color(1,1,1,0) ) );
-- Add time to the age
pAge:Anim( pAge+fAge() );

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

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

SetTexture("20");

-- A global variable that we can set from outside
gStarsActive = true

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   if gStarsActive then
      CreateParticles( seconds * 1 );
      gStarsActive = false;
   end
end

