//rainDrop1 and rainOverlay are defined as global variables
int howMuchRain = 10; //to make 10 raindrops at a time
int rainDropLength = 20; //each drop is 1 pixel wide, 20 pixels long
DynamicSprite *rainBackground;
DrawingSurface *rainDrawingSurface;
function makeItRain()
{
if(!IsGamePaused())
{
if(rainDrawingSurface != null)
{
rainDrawingSurface.Clear();
} else {
rainBackground = DynamicSprite.CreateFromExistingSprite(1234);
rainDrawingSurface = rainBackground.GetDrawingSurface();
}
if(Game.DoOnceOnly("initRain")){
SetTimerWithSeconds(13, 0.1);
}
if(IsTimerExpired(13))
{
for (int i = 0; i < howMuchRain; i++)
{
int coordX = Game.Camera.X + 1 + Random(Game.Camera.Width - 2);
int coordY = Game.Camera.Y + 1 + Random(Game.Camera.Height - rainDropLength - 2);
rainDrop1 = DynamicSprite.CreateFromBackground(GetBackgroundFrame(), coordX, coordY, 1, rainDropLength);
rainDrop1.Tint(1, 1, 1, 30, 100);
rainDrawingSurface.DrawImage(coordX, coordY-1, rainDrop1.Graphic);
}
rainOverlay = Overlay.CreateGraphical(0, 0, rainBackground.Graphic, true);
SetTimerWithSeconds(13, 0.15);
}
}
}
function late_repeatedly_execute_always()
{
makeItRain();
}