# Make it rain… again.

This is the updated version of my raincloud sketch, rewritten with functions and a few improvements. And now you can play with it directly in my blog! (If it doesn’t work, here’s the link.)

And here is the code:

```[code lang="java"]
//Kim Ash
//Raincloud program redone with functions.

int x;  //moving cloud position
int y;

int x1 = 180;  //stationary cloud 1 position
int y1 = 120;
int x2 = 690;  //stationary cloud 2 position
int y2 = 120;

int cloudfill = 255;

void setup()
{
size(700, 700);
}

void draw()
{
//sky
background(153, 218, 252);

smooth();

//sun
fill(255,255, 0);
ellipse(390, 97, 100, 100);

//grass
fill(85, 252, 3);
rect(0, 450, 700, 250);
for(int g=450; g<=700; g+=20)
{
stroke(29, 137, 0);
line(0, g, 700, g);
line(0, g, 700, g+40);
}

//println("x = " + mouseX + "t y = " + mouseY);
cloud(mouseX, mouseY);

scale(.9);
cloud(x1, y1);
scale(1.11);
scale(.8);
cloud(x2, y2);
scale(1.25);

//rain falls when the moving cloud covers the sun
if (mouseX >= 310 && mouseX <= 387 && mouseY >= 13 && mouseY <= 96)
{
cloudfill = 150;
for(int i=0; i<=200; i++)
{
//rain
fill(0, 0, 255);
rect(random(700), random(210,700), 2, 15);
}

}
else
cloudfill = 255;

}

void cloud(int x, int y)
{
noStroke();
fill(cloudfill);
ellipse(x, y, 110, 110);
ellipse(x-60, y+40, 110, 110);
ellipse(x+60, y+40, 110, 110);
ellipse(x+60, y+80, 250, 100);
ellipse(x-60, y+80, 250, 100);
ellipse(x, y+80, 250, 100);
}[/code]```