kPPS = 200;               -- Number of particles generated per second
kGravity = 1000;            -- Gravity in pixels/second/second

function Init()
  SetTexture("confetti2");
  SetBlendMode(kBlendNormal);
  SetNumParticles(200);
end

floor = math.floor

ParticlesPerSecond = NewParticleGenerator();

StopSpouting = NewTimeout(500);
TestDone = NewTimeout(2500);

function Update(ms)
  if (TestDone(ms)) then
    SetDone();
    return ;
  end
  local newParticles = ParticlesPerSecond( kPPS,ms );

  if (not StopSpouting(ms)) then
   InitPosition( "vRange", Vec3(-5,-10,0), Vec3(5,10,0) );
   InitVelocity( "vRange", Vec3(120,-500,0), Vec3(450, -1000, 0));
   InitScale( "fRange", 0.5, 1 );
   InitUp( "vRange", Vec3( -1.0, -1.0), Vec3( 1.0, 1.0 ));
   InitAge("iRange", 0, 0);
   InitExtra1("fRange",0,1);
   CreateParticles( newParticles );
  end

   Gravity(kGravity);

   Do("move");
   DoAge("iAge");
   DoScale("fScale",
      .5, 200, 
      1, 1500,
      .0, 1000);
   Do("expire", 2000)

   DoUp( "vRotate", -.6, .6 );
end

