-- Allocate values
pDirection = Allocate( 1 );
pSpin = Allocate( 1 );
pSpinSpeed = Allocate( 1 );
pSpin2 = Allocate( 1 );
pSpinSpeed2 = Allocate( 1 );
pSecondMove = Allocate( 1 );
pThirdMove = Allocate( 1 );
-- Set the particle texture
SetTexture("fly.png");
SetBlendMode(kBlendNormal);

SetNumParticles(10);    -- Create some particles

-- Initialize
pPosition:Init( fRange( Vec2( -30, -30), Vec2( 30, 30 ) ) );
pColor:Init( Color(1,1,1,0.9) );
pScale:Init(  1.0  );
-- pUp:Init( f2dRadius( 1 ) );   -- random radius
pSpin:Init( fRange( 0, 2*3.1415927 ) ); -- random orientation
pSpinSpeed:Init( fRange( 2, 3 ) ); -- random spin speed
pSpin2:Init( fRange( 0, 2*3.1415927 ) ); -- random orientation
pSpinSpeed2:Init( fRange( 1, 3 ) ); -- random spin speed
pSecondMove:Init( fRange( 30, 40) );
pThirdMove:Init( fRange( -30, -50) );
pDirection:Init( fPick( -1, 1 ) );


-- Animate
pPosition:Anim( pPosition + fTimeScale(f2dRotation( pSpin * 4 * pDirection )*30) + fTimeScale(f2dRotation( pSpin * 3 * pDirection )*(pSecondMove))+ fTimeScale(f2dRotation( pSpin2 * 3 * pDirection )*(pThirdMove))); 
pSpin:Anim( pSpin + fTimeScale( pSpinSpeed) ); -- spin update
pSpin2:Anim( pSpin2 + fTimeScale( pSpinSpeed2) ); -- spin update
-- pUp:Anim( f2dRotation( pSpin ) ); -- particle orientation


-- Expire particles which faded out completelly.

-- Create 10 flies
CreateParticles( 10);
-- A function to run as we're executing
-- seconds - how many seconds have elapsed
-- function Update(seconds)
   -- Create 10 particle per second
--   CreateParticles( seconds * 10 );
-- end

