mScale = GUI_Slider(
   90.00,
   "Scale",
   0,150);

mMaxDrift = GUI_Slider(
   -30.00,
   "Max Drift",
   -50,50);

mMinDrift = GUI_Slider(
   30.00,
   "Min Drift",
   -50,50);

mMaxRotation = GUI_Slider(
   0.40,
   "Max Rotation",
   -20,20);

mMinRotation = GUI_Slider(
   2.00,
   "Min Rotation",
   -20,20);

mEmitSpeed = GUI_Slider(
   0.10,
      "Emitter Speed",
      0,10);

mRadius = GUI_Slider(
   600.00,
      "Radius",
      0,600);

mMinSpeed = GUI_Slider(
   12.00,
      "Min Speed",
      0,100);

mMaxSpeed = GUI_Slider(
   16.00,
      "Max Speed",
      0,100);

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

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

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

gActive = true;

-- ------------------------------------------------------------
-- Define our particle characteristics
pVelocity = Allocate(2);
pSpin = Allocate(1);
pSpinSpeed = Allocate(1);
pFadeStart = Allocate(1);

SetTexture(mTextureName);
SetBlendMode(mBlendMode);

SetNumParticles(5);

-- ------------------------------------------------------------
-- Initialization rules.
-- 
-- The following rules define how particles are created.

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

pPosition:Init(Vec2(fRange(-mRadius,mRadius), 0) + dLocus);
pVelocity:Init(Vec2(fRange(mMinDrift, mMaxDrift), fRange(mMinSpeed,mMaxSpeed)));
pSpin:Init( fRange( 0, 2*3.1415927 ) );
pSpinSpeed:Init( fRange( mMinRotation, mMaxRotation ) );
pScale:Init( mScale/100 );
pColor:Init( Color(1,1,1,1) );
pFadeStart:Init(fPick(200,220));

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
--
-- The following rules define how particles animate.
-- Each rule is applied on each frame of animation.
pPosition:Anim( pPosition + fTimeScale(pVelocity));
pSpin:Anim( pSpin + fTimeScale( pSpinSpeed ) );
pUp:Anim( f2dRotation( pSpin ) );
pColor:Anim( 
   fFade( pPosition[2],
      Color(1,1,1,1), pFadeStart,
      Color(1,1,1,1), 30,
      Color(1,1,1,0) )
   );

-- General Anim functions
Anim( fExpire( fGreater(pPosition[2], 250) ) );

-- ------------------------------------------------------------

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

