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

mScale = GUI_Slider(
	0.00,
      "Initial Scale",
      0,3.0);

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

mMaxParticles = GUI_Slider(
	100.00,
      "Max Particles",
      0,100);

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

pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member
pSpin = Allocate(1); -- Allocate a TReal spin member
pSpinSpeed = Allocate(1); -- Allocate a TReal spin member
pOrigPosition = Allocate(2);
pSin = Allocate(1);
pLifeSpan = Allocate(1);

SetTexture( "particles/smoke" );
SetBlendMode(mBlendMode);
SetNumParticles(mMaxParticles);

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

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

if not dSinStart then
   dSinStart = fRange( 0, 1 );
end

pPosition:Init( dPosition );
pOrigPosition:Init( pPosition );
pVelocity:Init( fRange( Vec2(-0.75,-12.5), Vec2(0.75,-12.5) ) );
pScale:Init( mScale );
pAge:Init(0);
pSpin:Init( fRange( 0, 2*3.1415927 ) );
pSpinSpeed:Init( fRange( -3, 3 ) );
pSin:Init( dSinStart );
pLifeSpan:Init( fRange( 3000, 11000 ) );

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

pSin:Anim( pSin + fTimeScale( 1 ) );
pOrigPosition:Anim( pOrigPosition + fTimeScale( pVelocity ) );
pPosition:Anim( Vec2( pOrigPosition[1] + ( fSin( pSin * 3.1415926 ) * ( pSin + -5 ) ), pOrigPosition[2] ) );
pScale:Anim( pScale + fTimeScale(0.2) );

pColor:Anim( 
   fFade( pAge,
      Color(1,1,1,0.1),pLifeSpan,
      Color(1,1,1,0) )
   );

pSpin:Anim( pSpin + fTimeScale( pSpinSpeed ) );
pAge:Anim( pAge+fAge() );

Anim( fExpire( fGreater(pAge,pLifeSpan) ) );

-- ------------------------------------------------------------
-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   CreateParticles( seconds * mEmitSpeed );
end
