-- ================================================================================
gTexture = GUI_PickTexture("fx/star_big","Particle Texture");
gBlendMode = GUI_Select(
   kBlendAdditiveAlpha,
   "Blend Mode",
   {
      { description="Normal", value=kBlendNormal},
      { description="Additive Alpha", value=kBlendAdditiveAlpha},
      { description="Multiplicative", value=kBlendMultiplicative},
      { description="Subtractive", value=kBlendSubtractive},
      { description="Opaque", value=kBlendOpaque},
   }
);
gNumParticles = GUI_Slider(
   100,
   "Max Number of Particles",
   0,1000);
gPPS = GUI_Slider(
	10.00,
   "Particles Per Second",
   0,200);
gParticleLife = GUI_Slider(
	1000.00,
   "Particle Life",
   0,3000);
gInitColor = GUI_ColorPick(
223,55,60,255,
   "Initial Color");
gInitPosX = GUI_Slider(
	100.00,
   "Initial X Offset",
   0,100);
gInitPosY = GUI_Slider(
	100.00,
   "Initial Y Offset",
   0,100);
gInitVelX = GUI_Slider(
	5.00,
   "Initial X Velocity",
   -10,10);
gInitVelY = GUI_Slider(
	3.00,
   "Initial Y Velocity",
   -10,10);
gMinSpinSpeed = GUI_Slider(
	49.90,
   "Min Spin Speed",
   -50,50);
gMaxSpinSpeed = GUI_Slider(
   2.00,
   "Max Spin Speed",
   -50,50);
gInitWeight = GUI_Slider(
   0,
   "Initial Weight",
   -10,10);
gInitRot = GUI_Slider(
	-9.01,
   "Initial Rotation",
   -10,6.28);
gInitSize = GUI_Slider(
	0.30,
   "Initial Size",
   0.01,100);
gInitSizeRange = GUI_Slider(
	0.50,
   "Init Size Variation",
   0,100);
gVelocityOverTime = GUI_Graph(
   {
      Vec2(0.00,0.00),1000,
      Vec2(0.00,0.00)
   },
   Vec2(-5.00,-5.00),
   Vec2(5.00,5.00),
   {
      {0.00,0.00,time=0.00},
      {0.00,0.00,time=1000.00}
   },
   "Velocity Over Time");
gScaleOverTime = GUI_Graph(
   {
		1.00,248,
		0.00
	},
   0.00,
   10.00,
   {
		{1.00,time=0.00},
		{0.00,time=248.40}
	},
   "Scale Over Time");
gColorOverTime = GUI_Graph(
   {
		Color(0.85,0.11,0.24,1.00),77,
		Color(0.85,0.11,0.24,0.66),96,
		Color(0.80,0.79,0.15,0.98),107,
		Color(0.80,0.79,0.15,0.43),60,
		Color(0.32,0.58,0.64,0.87),85,
		Color(0.32,0.58,0.64,0.38),71,
		Color(0.32,0.58,0.64,0.70),61,
		Color(0.32,0.58,0.64,0.01),110,
		Color(0.32,0.58,0.64,0.40),123,
		Color(1.00,1.00,1.00,0.0)
	},
   Color(0,0,0,0),
   Color(1,1,1,1),
   {
		{0.85,0.11,0.24,1.00,time=0.00},
		{0.85,0.11,0.24,0.66,time=77.94},
		{0.80,0.79,0.15,0.98,time=174.22},
		{0.80,0.79,0.15,0.43,time=281.58},
		{0.32,0.58,0.64,0.87,time=342.21},
		{0.32,0.58,0.64,0.38,time=427.37},
		{0.32,0.58,0.64,0.70,time=499.31},
		{0.32,0.58,0.64,0.01,time=560.83},
		{0.32,0.58,0.64,0.40,time=671.82},
		{1.00,1.00,1.00,0.00,time=795.47},
	},
   "Color Over Time");
-- ================================================================================
pAge = Allocate(1); 
pVelocity = Allocate(2);
pRotation = Allocate(1);
-- ================================================================================
SetTexture(gTexture);
SetBlendMode(gBlendMode);
SetNumParticles(gNumParticles);
if not dLocus then
   dLocus= Vec2(0,0) ; 
end
pPosition:Init( dLocus+fRange(Vec2(-gInitPosX,-gInitPosY),Vec2(gInitPosX,gInitPosY)) );
pScale:Init( fRange(gInitSize,gInitSize+gInitSizeRange) );
pColor:Init(gInitColor);
pAge:Init(0);
pVelocity:Init(fRange(Vec2(-gInitVelX,-gInitVelY),Vec2(gInitVelX,gInitVelY)));
pRotation:Init(gInitRot);
pUp:Init(f2dRotation(pRotation));
-- ================================================================================
pAge:Anim( pAge+fAge() );
pVelocity:Anim(Vec2(0,gInitWeight)+pVelocity+fFade(pAge,toparams(gVelocityOverTime)));
pPosition:Anim(pPosition+pVelocity);
pColor:Anim(fFade(pAge,toparams(gColorOverTime)));
--pScale:Anim(pScale+fFade(pAge,toparams(gScaleOverTime)));
Anim( fExpire( fGreater(pAge,gParticleLife) ) );
-- ================================================================================
function Update(seconds)
   CreateParticles( seconds * gPPS );
end
