-- GLOBAL PARAMETERS THAT CAN BE USED TO ADJUST THIS PARTICLES

par_scale = 0.5;
par_range = 10;
par_per_second = 20;

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

-- Set the particle texture
SetTexture("mysmoke.xml");
SetBlendMode(kBlendNormal );

SetNumParticles(200); 

pPosition:Init( fRange( Vec2( -par_range, -45 ), Vec2( par_range, -45 ) ) );
pColor:Init( Color(1,1,1,1) );
pScale:Init( par_scale );
pUp:Init( Vec2( 0, -1 )  ) ;
pAge:Init( 0 ) ;
pLifeLen:Init( fRange( 300, 550 ) ) ;
pFrame:Init( fPick( 0, 1, 2, 1 ) ) ;
pVelocity:Init( fRange( Vec2( 0, -160 ), Vec2( 0, -180 ) ) ) ;

-- Fade the particles.

pAge:Anim( pAge+fAge() );
pColor:Anim( fFade( pAge, Color(1,1,1,1), pLifeLen, Color(1, 1, 1, 0 ) ) );
--pFrame:Anim( fFade(pAge, 0, pLifeLen, 3 ) ) ;

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

