-- Additional parameters

pVelocity = Allocate( 2 ) ;
-- pSpin = Allocate( 1 );
-- pSpinSpeed = Allocate( 1 );
-- pSpinSpeed2 = Allocate( 1 );
-- pFallDirection = Allocate( 1 );
-- pFallDistance = Allocate( 2 );
-- pTimes = Allocate( 3 );
-- pDirections = Allocate( 3);
pAge = Allocate( 1 );
pAge2 = Allocate( 1 );
pSpinSpeed = Allocate( 1 );
-- pFadeOut = Allocate ( 2 );
-- pAge2 = Allocate( 1 );
-- Set the particle texture
SetTexture("leaves_small.xml");
SetBlendMode(kBlendNormal);

-- Create some particles
SetNumParticles(100);    -- Create some particles

-- Init Particles
pPosition:Init( fRange(Vec2(-50,-10), Vec2(50,10))); -- initial position
pColor:Init( Color(1,1,1,1) ); -- blending color
pScale:Init( 1.0); -- initial size
-- CHANGE THIS TO CHANGE THE DIRECTION
pVelocity:Init( fRange( Vec2( -6, 15 ), Vec2( 6, 25 ) ) ) ; -- random velocity
-- pSpin:Init( fRange( 0, 2*3.1415927 ) ); -- random orientation
pSpinSpeed:Init( fRange( 300, 400 ) ); -- random spin speed



-- Move the particles
-- define the movement
pAge:Anim(  pAge + fAge()  );
-- fade out particle
pColor:Anim( fFade( pAge, Color(1,1,1,1), 7000, Color(1,1,1,1), 8000, Color(1,1,1,0) ) );

-- update movement
pPosition:Anim( pPosition + fTimeScale( pVelocity )  ); -- position update  40 scale the speed
-- pSpin:Anim( pSpin + fTimeScale( pSpinSpeed) ); -- spin update
-- pUp:Anim( f2dRotation( pSpin) ); -- particle orientation
pAge2:Anim(  fLess( pAge2, pSpinSpeed ) * pAge2 + fAge());
pFrame:Anim( fFade( pAge2, 0, pSpinSpeed, 3 ) );
-- Expire particles older than 8sec
Anim( fExpire( fGreater(pAge,  8000) ) );

-- intial
CreateParticles( 1 );
-- A function to run as we're executing
-- seconds - how many seconds have elapsed


-- USE THIS TO CHANGE THE AMOUNT OF LEAVES
-- CAN BE DONE IN THE CODE !!
LeavesPerSecond = 0.5;

function Update(seconds)
   -- Create 10 particles per second
   CreateParticles( seconds * LeavesPerSecond );
end

---- Additional parameters
--
--pVelocity = Allocate( 2 ) ;
--pSpin = Allocate( 1 );
--pSpinSpeed = Allocate( 1 );
--pSpinSpeed2 = Allocate( 1 );
--pFallDirection = Allocate( 1 );
--pFallDistance = Allocate( 2 );
--pTimes = Allocate( 3 );
--pDirections = Allocate( 3);
--pAge = Allocate( 1 );
--pFadeOut = Allocate ( 2 );
--pAge2 = Allocate( 1 );
---- Set the particle texture
--SetTexture("leaves_small.xml");
--SetBlendMode(kBlendNormal);
--
---- Create some particles
--SetNumParticles(50);    -- Create some particles
--
---- Init Particles
--pPosition:Init( fRange(Vec2(-20,-20), Vec2(20,20))); -- initial position
--pColor:Init( Color(1,1,1,1) ); -- blending color
--pScale:Init( 1); -- initial size
---- CHANGE THIS TO CHANGE THE DIRECTION
--pVelocity:Init( fRange( Vec2( 05, 03 ), Vec2( 10, 06 ) ) ) ; -- random velocity
--pSpin:Init( fRange( 0, 2*3.1415927 ) ); -- random orientation
--pSpinSpeed:Init( fRange( -3, 3 ) ); -- random spin speed
--pSpinSpeed2:Init( fRange( 200, 400 ) ); -- random spin speed
--pFallDirection:Init( 1.0 );
--pUp:Init( f2dRadius( pSpin ) );   -- random radius
--pAge:Init( 0 );
--pTimes:Init( fRange( Vec3(1500,3500,5000), Vec3(2000,4000,5500) ) );
--pDirections:Init( fRange( Vec3( 0.3, 2.5, 0.3), Vec3( 1.0, 2.8, 0.7) ) );
--pAge2:Init( fRange( 0, 500) );
--
--
--
---- Move the particles
---- define the movement
--pAge:Anim(  pAge + fAge()  );
--pAge2:Anim(  fLess( pAge2, pSpinSpeed2 ) * pAge2 + fAge());
--pFallDirection:Anim( fFade( pAge, pDirections[0], pTimes[0] , pDirections[1], pTimes[1] , pDirections[2], pTimes[2], pDirections[1], pTimes[2] + 3000, pDirections[2]));
--pFallDistance:Anim( f2dRotation( pFallDirection) );
---- fade out particle
--pColor:Anim( fFade( pAge, Color(1,1,1,1), 1500, Color(1,1,1,1), 2000, Color(1,1,1,1), 3000, Color(1,1,1,0) ) );
--
---- update movement
--pPosition:Anim( pPosition + fTimeScale( pVelocity ) +  fTimeScale(pFallDistance * 20)  ); -- position update  40 scale the speed
--pSpin:Anim( pSpin + fTimeScale( pSpinSpeed) ); -- spin update
--pUp:Anim( f2dRotation( pSpin + pFallDirection ) ); -- particle orientation
--pFrame:Anim( fFade( pAge2, 0, pSpinSpeed2, 3 ) );
---- Expire particles lower than 600
--Anim( fExpire( fGreater(pAge,  3000) ) );
--
---- intial
--CreateParticles( 1 );
---- A function to run as we're executing
---- seconds - how many seconds have elapsed
--
--
---- USE THIS TO CHANGE THE AMOUNT OF LEAVES
---- CAN BE DONE IN THE CODE !!
--LeavesPerSecond = 2;
--
--function Update(seconds)
--   -- Create 10 particles per second
--   CreateParticles( seconds * LeavesPerSecond );
--end
--
--