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

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

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

gScale = GUI_Slider(
   0.12,
      "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/sparkle","Particle Texture");

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

pRotation = Allocate(1);
pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member
SetTexture(gTextureName);
SetBlendMode(gBlendMode);
SetNumParticles(gMaxParticles);

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

-- Pick a velocity within a range
pVelocity:Init( fRange( Vec2(-1,-1), Vec2(1,1) ));
pRotation:Init(fRange(0.0,0.5));
pUp:Init(f2dRotation(pRotation));
-- Start scale at 0.5
pScale:Init( gScale );

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

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
--
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,1.0),100,
      Color(1,1,1,0.7),700,
      Color(1,1,1,0) ) -- to final color
   );

-- Age the particle using age function
pAge:Anim( pAge+fAge() );
pScale:Anim(pScale-pAge*0.00001);
-- General Anim functions
-- Expire particles over 700 ms old
Anim( fExpire( fGreater(pAge,800) ) );

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

