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

mLimitRadius = GUI_Slider(
   80.00,
   "Max Radius",
   0,100);


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

mMinSpeed = GUI_Slider(
	40.00,
      "Min Speed",
      0,300);

mMaxSpeed = GUI_Slider(
	60.00,
      "Max Speed",
      0,300);

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

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

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

gActive = true;
gStop = 0;


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

pAge = Allocate(1);
pVelocity = Allocate(1);
pDirection = Allocate(2);

SetTexture(mTextureName);
SetBlendMode(mBlendMode);

--SetNumParticles(mEmitSpeed * mLifetime);
SetNumParticles(1000);

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

-- Define dLocus for FluidFX; 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

-- Pick a position randomly, within a range of values.
-- dLocus is defined in swarm.cpp and added to the random
-- range
pVelocity:Init( fRange(mMinSpeed, mMaxSpeed) );
pDirection:Init( f2dRadius(1) );
pPosition:Init( pDirection * mRadius + dLocus );
pColor:Init( Color(1,1,1,1) );
-- 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(pPosition-dLocus));
pPosition:Anim( pPosition + pDirection * fTimeScale(pVelocity));

-- Add gravity scaled by time to velocity
--pVelocity:Anim(pVelocity + fTimeScale(Vec2(0, mGravity)));

-- Fade (using age) from white to yellow to black. Assumes
-- the first parameter is a number of elapsed milliseconds,
-- though can work to linearly interpolate using first 
-- scalar parameter between any value types.


-- Age the particle using age function
pAge:Anim( fDistance(pPosition, dLocus) );
pColor:Anim( fFade(pAge, Color(1,1,1,1), mLimitRadius, Color(1,1,1,0)) );
-- General Anim functions
Anim( fExpire( fGreater(fDistance(pPosition, dLocus), mLimitRadius) ) );


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

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

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

function Update(seconds)
   if gActive == true then
      --if not timeout(seconds) and gStop == 0 then
         CreateParticles(seconds * mEmitSpeed);
      --else
         --if GetParticleCount() == 0 then
            --Done();
         --end
      --end
   end -- gActive
end

