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

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

SetNumParticles(200); 

pPosition:Init( fRange( Vec2( -10, 0 ), Vec2( 10, 0 ) ) );
pColor:Init( Color(1,1,1,1) );
pScale:Init( 1.0 );
pUp:Init( Vec2( 0, -1 )  ) ;
pAge:Init( 0 ) ;
pLifeLen:Init( fRange( 1500, 2000 ) ) ;
pFrame:Init( fPick( 0, 1, 2, 3 ) ) ;
pVelocity:Init( fRange( Vec2( 0, -80 ), Vec2( 0, -100 ) ) ) ;

-- Fade the particles.

pAge:Anim( pAge+fAge() );
pColor:Anim( fFade( pAge, Color(1,1,1,0.1), pLifeLen, Color(1, 1, 1, 0 ) ) );

-- 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)
   CreateParticles( seconds * 10 );
end

