
-- Rain parameters
kPPS = 15;               -- Number of particles generated per second
kGravity =400 ;            -- Gravity in pixels/second/second

-- kBlendNormal
-- kBlendOpaque
-- kBlendAdditive
-- kBlendAdditiveAlpha
-- kBlendSubtractive
-- kBlendLit

function Init()
  SetTexture("smoke");
  SetBlendMode(kBlendLit);
  SetNumParticles(100);
end

floor = math.floor
delayBeforeStart=800;
ParticlesPerSecond = NewParticleGenerator();
StopSpouting = NewTimeout(delayBeforeStart+2500);
TestDone = NewTimeout(4000+delayBeforeStart);
StartTime = NewTimeout(delayBeforeStart);

function Update(ms)

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

  if (not StopSpouting(ms)) then
   InitPosition( "vRange", Vec3(-25, -15), Vec3(15, 8) );
   InitVelocity( "vRange", Vec3(-.2,.5), Vec3(.2,.10) );
   InitScale( "fRange", 0.2, .5 );
   InitAge("iRange", 0, 4);
   CreateParticles(newParticles);
  end

Gravity(-.25* kGravity);

   Do("move");
   DoAge("iAge");
 DoColor("cFade",
      Color(1, 1, 1, 5), 200,
      Color(1, 1, 1, 5), 200,
      Color(125, 125, 125, 5));
   DoScale("fScale",
      .5, 1000,
      .30, 900);
   Do("expire", 800)

--DoUp( "vRotate", -25, 65 );


end

