mParticleCount = GUI_Slider(
	5.00,
      "Particle Count",
      0,10);

mMinCenterOffset = GUI_Slider(
   0.00,
      "Min Center Offset",
      0,100);

mMaxCenterOffset = GUI_Slider(
   0.00,
      "Max Center Offset",
      0,100);

mMinFlightRadius = GUI_Slider(
	12.00,
      "Min Flight Radius",
      0,100);

mMaxFlightRadius = GUI_Slider(
	22.00,
      "Max Flight Radius",
      0,100);

mFlightRadiusGraph = GUI_Graph(
   {
      1.00,133,
      1.41,120,
      1.34,140,
      0.73,259,
      1.28,191,
      0.81,158,
      1.00
   },
   0.00,
   2.00,
   {
      {1.00,time=0.00},
      {1.41,time=132.81},
      {1.34,time=252.97},
      {0.73,time=393.17},
      {1.28,time=651.79},
      {0.81,time=842.49},
      {1.00,time=1000.00}
   },
   "Flight Radius Modifier");


mMinFlightSpeed = GUI_Slider(
   0.60,
      "Min Flight Speed (revolutions per second)",
      0,5);

mMaxFlightSpeed = GUI_Slider(
   0.80,
      "Max Flight Speed (revolutions per second)",
      0,5);

mMinScale = GUI_Slider(
	2.00,
      "Min Scale",
      0,5);

mMaxScale = GUI_Slider(
	2.50,
      "Max Scale",
      0,5);

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

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

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

PI = 3.1415926536

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

pCenter = Allocate(2);
pRadiusCoeff = Allocate(1);
pRadiusCoord = Allocate(1);
pRadiusSpeed = Allocate(1);
pRadius = Allocate(1);
pRotationSpeed = Allocate(1);
pRotationAngle = Allocate(1);

SetTexture(mTextureName);
SetBlendMode(mBlendMode);

SetNumParticles(mParticleCount + 1);

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

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

-- ------------------------------------------------------------
-- Initialization rules.

pCenter:Init(
   f2dRotation(fClosedCycle(0, 2 * PI, mParticleCount + 1) + PI / mParticleCount) *
   fRange(mMinCenterOffset, mMaxCenterOffset));
pRadiusCoeff:Init(fRange(mMinFlightRadius, mMaxFlightRadius));
pRadiusSpeed:Init(fRange(0.8, 1.5));
pRadiusCoord:Init(fRange(0, 1000));
pRadius:Init(pRadiusCoeff);
pRotationSpeed:Init(fPick(-1, 1) * fRange(mMinFlightSpeed, mMaxFlightSpeed) * 2 * PI);
pRotationAngle:Init(fRange(-PI, PI));

pPosition:Init(dLocus + pCenter + f2dRotation(pRotationAngle) * pRadius);

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

-- ------------------------------------------------------------
-- Particle Parameter Animation Functions

pRadiusCoord:Anim(pRadiusCoord + fAge() * pRadiusSpeed - fGreater(pRadiusCoord, 1000) * 1000);
pRadius:Anim(pRadiusCoeff * fFade(pRadiusCoord, toparams(mFlightRadiusGraph)));
--pRadius:Anim(0);
pRotationAngle:Anim(pRotationAngle + fTimeScale(pRotationSpeed));
pPosition:Anim(dLocus + pCenter + f2dRotation(pRotationAngle) * pRadius);
--pPosition:Anim(dLocus + pCenter + Vec2(0, pRadiusCoeff * fFade(pRadiusCoord, toparams(mFlightRadiusGraph))));

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

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

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

function Update(seconds)
end
