mLifetime = GUI_Slider(
	0.50,
      "Particle Lifetime",
      0.1,3.0);

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

mFocusCoeff = GUI_Slider(
   0.60,
      "Focus Coeff",
      0,1);

mMinSpeedY = GUI_Slider(
   -60.00,
      "Min Speed Y",
      -500,500);

mMaxSpeedY = GUI_Slider(
   -80.00,
      "Max Speed Y",
      -500,500);

mMinScale = GUI_Slider(
   1.00,
      "Min Scale",
      0,3.0);

mMaxScale = GUI_Slider(
   4.00,
      "Max Scale",
      0,3.0);

mTextureName = GUI_PickTexture("fx/world3/bud_2_particle","Particle Texture");

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

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

gActive = true;

PI = 3.1415926536;

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

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


-- Set the particle texture
SetTexture(mTextureName);

-- Set the blend mode
SetBlendMode(mBlendMode);

-- 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(mEmitSpeed * (mLifetime + 1));

-- ------------------------------------------------------------
-- External params.

if not dLocus then
   dLocus = Vec2(0, 0);
end

-- ------------------------------------------------------------
-- Initialization

pPosition:Init(Vec2(fRange(-15, 15), fRange(-15, 15)) + dLocus);
pVelocity:Init(Vec2(
   (pPosition[1] - dLocus[1]) * -mFocusCoeff,
   fRange(mMinSpeedY, mMaxSpeedY)));

pStartScale:Init(fRange(mMinScale, mMaxScale));
pScale:Init(pStartScale);

pAge:Init(0);

-- ------------------------------------------------------------
-- Animation

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

pScale:Anim(pScale - fTimeScale(pStartScale / mLifetime));

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

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

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