mDuration = GUI_Slider(
   0.20,
   "Effect Duration",
   0,10);

mLifetime = GUI_Slider(
   500.00,
   "Particle Lifetime",
   0,5000);

mEmitSpeed = GUI_Slider(
   100.00,
   "Emit Speed",
   0,500);

gControl0006 = GUI_Slider(
   -100,
   "Gravity",
   -1000,1000);

gControl0005 = GUI_Slider(
   0.00,
   "Scale Per Second",
   0,10);

gControl0004 = GUI_Slider(
   300.00,
   "Particle Count",
   0,1000);

gControl0003 = GUI_Slider(
   3.00,
   "Intial Scale",
   0,10);

gControl0002 = GUI_Slider(
   100.00,
   "Initial Velocity Max",
   0,666);

gControl0001 = GUI_Slider(
   50.00,
   "Initial Velocity Min",
   0,100);

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}
   }
);

SetTexture("white_dot");

-- ------------------------------------------------------------
-- Initialization phase

-- Define our custom particle properties
pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age 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(gBlendMode);

-- Set the blend mode
--SetTexture('fx/blue_dot');

-- 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(gControl0004);

-- ------------------------------------------------------------
-- Particle Initialization Rules.

pPosition:Init(dLocus + f2dRadius(fRange(0, 60)));
pVelocity:Init(f2dRadius(fRange(gControl0001, gControl0002)));

pScale:Init( gControl0003 );

pColor:Init(Color(1,1,1,1));

pAge:Init(0);

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions

pPosition:Anim( pPosition + fTimeScale(pVelocity) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,gControl0006)) );

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

pColor:Anim(fFade(pAge,
      Color(1,1,1,0.8), mLifetime, 
      Color(0,0,0,0)));

pAge:Anim(pAge+fAge());
Anim( fExpire( fGreater(pAge,mLifetime) ) );

-- A function to run as we're executing
-- seconds - how many seconds have elapsed

timeout = NewTimeout(mDuration);

function Update(seconds)
   if not timeout(seconds) then
      CreateParticles(seconds * mEmitSpeed);
   end
end
