mLifetime = GUI_Slider(
	400.00,
      "Particle Lifetime",
      0.1,2000);

mEmitSpeed = GUI_Slider(
	50.00,
      "Emitter Speed",
      0,200);

mRadius = GUI_Slider(
	23.00,
      "Radius",
      0,100);

mMinSpeed = GUI_Slider(
   80.60,
      "Min Speed",
      0,200);

mMaxSpeed = GUI_Slider(
   140.80,
      "Max Speed",
      0,200);

mTextureName = GUI_PickTexture("fx/main_menu/boiler_particle","Particle Texture");

mBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
      "Blend Mode",
      {
         { description="Normal", value=kBlendNormal},
         { description="Additive", value=kBlendAdditiveAlpha}
      }
);

-- ------------------------------------------------------------
-- Globals

gActive = true;


-- ------------------------------------------------------------
-- Define our particle characteristics
pAge = Allocate(1); -- Allocate a TReal age member
pVelocity = Allocate(2);
SetTexture(mTextureName);
SetBlendMode(mBlendMode);
SetNumParticles(mEmitSpeed * mLifetime);

-- ------------------------------------------------------------
-- Initialization rules.
if not dLocus then
   dLocus= Vec2(0,0) ; 
end

pPosition:Init(Vec2(fRange(-mRadius,mRadius), 0) + dLocus);
pVelocity:Init(fPick(Vec2(0,0), Vec2(0, fRange(-mMaxSpeed,-mMinSpeed)) ) );
pColor:Init( Color(1,1,1,1) );
pAge:Init(0);
pScale:Init(1);

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
pPosition:Anim( pPosition + fTimeScale(pVelocity));
pColor:Anim( 
   fFade( 
      pAge,
      Color(1,1,1,0.8), mLifetime, 
      Color(0,0,0,0) ) );
pAge:Anim( pAge+fAge() );
pScale:Anim( fFade(pAge, 0.5, mLifetime, 0.2) );
Anim( fExpire( fGreater(pAge,mLifetime) ) );

-- ------------------------------------------------------------
-- Create initial particles (optional)
-- CreateParticles( 1 );

timeout = NewTimeout(mTimer);

function Update(seconds)
   if gActive then
     CreateParticles(seconds * mEmitSpeed);
   end -- gActive
end
