-- GLOBAL PARAMETERS THAT CAN BE USED TO ADJUST THIS PARTICLES
par_scale = 1.0; -- this parameter sets size of the flames
par_per_second = 1.0; -- this parameter controls how many particles is created per second
-- THIS PARAMETER CONTROLS BEHAVIOUR
bActive = true; -- this turns on and off creating particles

pAge = Allocate(1) ; -- Allocate a parameter representing age and length of life
pLifeLen = Allocate( 1 ) ;
pVelocity = Allocate( 2 ) ;
pInitFrame = Allocate( 1 ); 

-- Set the particle texture
SetTexture("candle_smoke.xml");
SetBlendMode(kBlendAdditiveAlpha );

SetNumParticles(10); 

-- pPosition:Init( fRange(Vec2(-1,-5 ), Vec2(1,0)) );
pColor:Init( Color(1,1,1,1) );
pScale:Init( par_scale );
pUp:Init( Vec2( 0, -1 )  ) ;
pAge:Init( 0 ) ;
pLifeLen:Init( fRange( 4000, 8000 ) ) ;
pVelocity:Init( fRange( Vec2( 0, -10 ), Vec2( 0, -25 ) ) ) ;

-- Fade the particles.

pAge:Anim( pAge+fAge() );
pColor:Anim( fFade( pAge, Color(1,1,1,0.0), pLifeLen/4, Color(1, 1, 1, 1.0 ), pLifeLen, Color(1, 1, 1, 0.0 ) ) );
pFrame:Anim( fFade( pAge, 0, pLifeLen/3, 7) );



-- Expire particles which faded out completelly.

pPosition:Anim( pPosition + fTimeScale( pVelocity ) );
Anim(  fExpire(  fGreater( pAge, pLifeLen ) )  ) ;

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
function Update(seconds)
   -- Create 50 particle per second

      CreateParticles( seconds * par_per_second );

end

