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

gControl0013 = GUI_Slider(
   2,
   "Particles Per Second",
   0,100);

gControl0012 = GUI_Slider(
   1000,
   "Age",
   0,5000);

gControl0011 = GUI_Slider(
   -100.00,
   "Gravity",
   -1000,1000);

gControl0010 = GUI_Slider(
   1.0,
   " Scale Per Second",
   0,100);

gControl0009 = GUI_Slider(
   0.5,
   "Start Scale",
   0,100);

gControl0008 = GUI_Slider(
   1.5,
   "Max initial Velocity",
   0,100);

gControl0007 = GUI_Slider(
   0.5,
   "Min initial Velocity",
   0,100);

gControl0006 = GUI_Slider(
   10,
   "Particle Count",
   0,1000);

gControl0005 = GUI_PickTexture("fx/white_dot","Texture");

gControl0004 = GUI_Slider(
   20,
   "Initial Position Max X",
   -100,100);

gControl0003 = GUI_Slider(
   20,
   "Initial Position Max X",
   -100,100);

gControl0002 = GUI_Slider(
   -20,
   "Initial Position Max X",
   -100, 100);

gControl0001 = GUI_Slider(
   -20,
   "Initial Position Min Y",
   -100, 100);

-- ------------------------------------------------------------
-- Define our particle characteristics

pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member


-- Set the blend mode
SetBlendMode(gBlendMode);
SetTexture(gControl0005);
SetNumParticles(gControl0006);

-- ------------------------------------------------------------
if not dLocus then
   dLocus= Vec2(0,0) ; 
end
pPosition:Init(fRange(Vec2(gControl0001, gControl0002), Vec2(gControl0003, gControl0004))  + dLocus );

pVelocity:Init(((pPosition - dLocus) + fRange(Vec2(-3,-3), Vec2(3,3))) * fRange(gControl0007, gControl0008));

pScale:Init( gControl0009 );
pColor:Init(fPick(Color(1, 0.2, 0.2, 1), Color(1, 1, 0.2, 1), Color(0.25,0.25,1,1)));
pAge:Init(0);

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

pScale:Anim( pScale + fTimeScale(gControl0010) );

pVelocity:Anim( pVelocity + fTimeScale(Vec2(0, gControl0011)));

pAge:Anim( pAge+fAge() );

pColor:Anim(fAlpha(pColor, fFade( pAge, 0.95, 700, 0.9, 300, 0.05 )));
   
Anim( fExpire( fGreater(pAge, gControl0012) ) );

-- ------------------------------------------------------------
gActive = true;
function Update(seconds)
   if gActive then
      CreateParticles(seconds * gControl0013);
   elseif (GetParticleCount() == 0) then
      Done();
   end
end
