gControl0009 = GUI_Slider(
   30.00,
   "Particles Per Second",
   0,5000);

gControl0008 = GUI_Slider(
   0.20,
   "Effect Time",
   0,10);

gControl0007 = GUI_Slider(
   715.00,
   "Age",
   0,5000);

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

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

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

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

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

gControl0001 = GUI_Slider(
   100.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("boiler_boil");

gFadeSpeed1 = GUI_Slider(
   916.00,
   "White Fade Speed",
   0,2000);
-- ------------------------------------------------------------
-- 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);

-- ------------------------------------------------------------
-- 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.

-- Pick one of two positions randomly, and add dLocus.
-- dLocus is defined in swarm.cpp and added to the random
-- range
pPosition:Init( dLocus + Vec2(fRange(-30,30), fRange(-30,30)) );

-- Pick a velocity from a range
pVelocity:Init( f2dRadius(fRange(gControl0001, gControl0002)));

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

-- Start scale out as 0.5
pScale:Init( gControl0003 );

-- 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.

-- Add velocity scaled by time to position
pPosition:Anim( pPosition + fTimeScale(pVelocity) );

pScale:Anim( pScale + fTimeScale(gControl0005) );
pVelocity:Anim( pVelocity + fTimeScale(Vec2(0,gControl0006)) );
pColor:Anim( 
   fFade( 
      pAge,
      Color(1,1,1,0.8), gFadeSpeed1, 
      Color(0,0,0,0) ) );
-- Add time to the age
pAge:Anim( pAge+fAge() );

Anim( fExpire( fGreater(pAge,gControl0007) ) );

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
gActive = true;
gTime = 0;
gDelayTime = 0;
function Update(seconds)
   if gActive then
      gDelayTime = gDelayTime - seconds;
      if gDelayTime < 0 then
         gDelayTime = 0;

         gTime = gTime + seconds;
         CreateParticles( seconds * gControl0009 );
         if gTime > gControl0008 then 
            gActive = false;
         end

      end
   end
end
