
gBlur = GUI_Slider(
   11.75,
   "Blur Generation Range",
   0,50);

gDrift = GUI_Slider(
   0.00,
   "Drift Velocity",
   0,100);

gEmitSpeed = GUI_Slider(
   200.00,
      "Emitter Speed",
      0,200);

gScale = GUI_Slider(
   1.24,
      "Scale",
      0,3.0);

gBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
   "Blend Mode",
   {
      { description="Normal", value=kBlendNormal},
      { description="Additive Alpha", value=kBlendAdditiveAlpha},
      { description="Subtractive", value=kBlendSubtractive},
      { description="Multiplicative", value=kBlendMultiplicative},
      { description="Opaque", value=kBlendOpaque}
   }
);

gTextureName = GUI_PickTexture("fx/star2","Particle Texture");

gMaxParticles = GUI_Slider(
	172.00,
      "Max Particles",
      0,1000);

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
SetTexture(gTextureName);
SetBlendMode(gBlendMode);
SetNumParticles(gMaxParticles);

pPosition:Init( fRange( Vec2(-10,-10), Vec2(10,10) )+dLocus );

-- Pick a velocity within a range
pVelocity:Init( fRange( Vec2(-100,-100), Vec2(100,100) ) );

-- Start scale at 0.5
pScale:Init( gScale );

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

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
--
--pScale:Anim(fRange(3.0,4.0));

-- Start initial rotation as a random angle
pSpin:Init( fRange( 0, 2*3.1415927 ) );

-- Start spin velocity random from -10 to 10
pSpinSpeed:Init( fRange( -3, 3 ) );

-- Spin by pSpinSpeed scaled by time
pSpin:Anim( pSpin + fTimeScale( pSpinSpeed ) );

pPosition:Anim( pPosition + fTimeScale(pVelocity) );

-- Fade (using age) from white to yellow to black. Assumes
-- the first parameter is a number of elapsed milliseconds,
-- though can work to linearly interpolate using first 
-- scalar parameter between any value types.
pColor:Anim( 
   fFade( pAge,
      Color(1,1,1,0),100,
      Color(1,1,1,0.063),900,
      Color(1,1,1,0) ) -- to final color
   );

-- Age the particle using age function
pAge:Anim( pAge+fAge() );

-- General Anim functions
-- Expire particles over 700 ms old
Anim( fExpire( fGreater(pAge,1000) ) );

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   CreateParticles( seconds * gEmitSpeed );
end

