gBlinkOnTime = GUI_Slider(
	2.00,
	"Blink On Time",
	0,5);

gBlinkOffTime = GUI_Slider(
	0.50,
	"Blink Off Time",
	0,5);

local gBounceTime = GUI_Slider(
   10.00,
   "Bounce Time",
   0.1,10);

local gHeight = GUI_Slider(
   4.00,
   "Bounce Height",
   1,200);

local gSpeed = GUI_Slider(
   0.50,
   "Bounce Speed",
   .01,200);





local kTextureHalfHeight = 32; 

-- ------------------------------------------------------------
-- Initialization phase

-- Define our custom particle properties
pAge = Allocate(1) ; -- Allocate a TReal age member
pHeight = Allocate(2);
pSin = Allocate(2);
pSin2 = Allocate(2);


-- dLocus is a data source: An external connection to the particle
-- system. Here we define dLocus for FluidFX, since FluidFX doesn't know
-- to provide the data source; 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

if not dUp then
   dUp= Vec2(0,-1) ; 
end


-- Set the particle texture
SetTexture("tutorial_arrow_offscreen");

-- Set the blend mode
SetBlendMode(kBlendNormal);

-- 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(1);    

-- ------------------------------------------------------------
-- Action Phase

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

-- Pick one of two positions randomly, and add dLocus.
-- dLocus is defined in swarm.cpp and added to the random
-- range


pUp:Init(dUp);

-- Start color (tint) off as white (natural color of image)
pColor:Init( Color(1,1,1,1) );

-- Start scale out as 0.5
pScale:Init( 1.0 );

-- Start age as 0 milliseconds
pAge:Init(0);

pSin:Init(Vec2(0,0));

pHeight:Init(0);
pPosition:Init( dLocus + Vec2(0, pHeight));





-- ------------------------------------------------------------
-- Particle Parameter Animation Functions
--
-- The following rules define how particles animate.
-- Each rule is applied on each frame of animation.
local heightOffset =
   Vec2(
      -(gHeight/2) - kTextureHalfHeight,  
      -(gHeight/2) - kTextureHalfHeight
   );


pSin:Anim(
   (f2dRotation(pAge*6.28*gSpeed)));

pSin2:Anim(
   (f2dRotation(pSin[1] * 3.14)));



pHeight:Anim(
   (pSin2 * (-gHeight/2)) - 
   heightOffset);

pPosition:Anim( dLocus + (Vec2(pHeight[1]*pUp[1],pHeight[1]*pUp[2])) );
pUp:Anim(dUp);


-- Add time to the age
pAge:Anim( pAge+fAge() );

pColor:Anim( fFade(pAge,Color(1,1,1,1),gBlinkOnTime*1000,Color(1,1,1,1), 0, Color(1,1,1,0)) );
Anim( fExpire( fGreater(pAge,1000 * (gBlinkOnTime+gBlinkOffTime)) ) );

-- A global variable that we can set from outside
local gActive = true
-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   if (gActive) then
      CreateParticles( seconds * 100 );
   end
end

