gBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
   "Blend Mode",
   {
      { description="Normal", value=kBlendNormal},
      { description="Additive Alpha", value=kBlendAdditiveAlpha},
      { description="Subtractive", value=kBlendSubtractive},
      { description="Multiplicative", value=kBlendMultiplicative},
      { description="Opaque", value=kBlendOpaque}
   }
);
gControl0013 = GUI_PickTexture("fx/plants/snowflake","Texture");

gControl0012 = GUI_Slider(
   4.00,
   "Particles Count",
   0,100);

gControl0011 = GUI_Slider(
   1.50,
   "Particles per Second",
   0,100);

gControl0010 = GUI_Slider(
   1000.00,
   "Age",
   0,5000);

gControl0009 = GUI_Slider(
   20,
   "Initial Pos Y Max",
   -100,100);

gControl0008 = GUI_Slider(
   20,
   "Initial Pos X Max",
   -100,100);

gControl0007 = GUI_Slider(
   -20,
   "Initial Pos Y Min",
   -100,100);

gControl0006 = GUI_Slider(
   -20,
   "Initial Pos X Min",
   -100,100);

gControl0005 = GUI_Slider(
   0.50,
   "ScalePerSecond",
   0,100);

gControl0004 = GUI_Slider(
   0.60,
   "Initial Scale",
   0,100);

gControl0003 = GUI_Slider(
	-90.00,
   "Gravity",
   -1000,1000);

gControl0002 = GUI_Slider(
	0.00,
   "Initial Velocity Max",
   0,100);

gControl0001 = GUI_Slider(
	0.00,
   "Initial Velocity Min",
   0,100);

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

pVelocity = Allocate(2) ; -- Allocate a Vec2 velocity member
pAge = Allocate(1) ; -- Allocate a TReal age member


-- Set the blend mode
SetBlendMode(gBlendMode);
SetTexture(gControl0013);
SetNumParticles(gControl0012);

-- ------------------------------------------------------------
if not dLocus then
   dLocus= Vec2(0,0) ; 
end
pPosition:Init(fRange(Vec2(gControl0006, gControl0007), Vec2(gControl0008, gControl0009))  + dLocus );

pVelocity:Init(((pPosition - dLocus) + fRange(Vec2(-3,-3), Vec2(3,3))) * fRange(gControl0001, gControl0002));

pScale:Init( gControl0004 );
pAge:Init(0);

-- ------------------------------------------------------------
pPosition:Anim( pPosition + fTimeScale(pVelocity) );

pScale:Anim( pScale + fTimeScale(gControl0005) );

pVelocity:Anim( pVelocity + fTimeScale(Vec2(0, gControl0003) ));

pAge:Anim( pAge+fAge() );

pColor:Anim(fAlpha(pColor, fFade( pAge, 1, 700, 0.9, 300, 0.2 )));
   
Anim( fExpire( fGreater(pAge, gControl0010) ) );

-- ------------------------------------------------------------
gActive = true;
function Update(seconds)
   if gActive then
      CreateParticles(seconds * gControl0011);
   end
end
