# Make it rain!

Here is a little applet I wrote in Processing for my ICM homework last week. When you move the cloud over the sun, all of the clouds will start to rain on the grass below.

http://itp.nyu.edu/~ka1019/ICM/raincloud/

It’s a little buggy–I think I need to fix the rules for where the mouse should be when it rains. I also know that this will be at least ten times better when I learn classes. I had a tough time understanding them in college, especially since we only spent about one month on Java in my Intro to Java and C class (roughly nine years ago), and the refresher course I took this fall was only on C.

```[code lang="java"]
int x;  //moving cloud position
int y;

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

float rx = random(700);  //raindrop position
float ry = random(261,700);

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);
}

noStroke();
x = mouseX;
y = mouseY;

//stationary cloud #1
fill(255);
ellipse(x1, y1, 110, 110);
ellipse(x1-60, y1+40, 110, 110);
ellipse(x1+60, y1+40, 110, 110);
ellipse(x1+60, y1+80, 250, 100);
ellipse(x1-60, y1+80, 250, 100);
ellipse(x1, y1+80, 250, 100);

//stationary cloud #2
fill(255);
ellipse(x2, y2, 110, 110);
ellipse(x2-60, y2+40, 110, 110);
ellipse(x2+60, y2+40, 110, 110);
ellipse(x2+60, y2+80, 250, 100);
ellipse(x2-60, y2+80, 250, 100);
ellipse(x2, y2+80, 250, 100);

//moving cloud
fill(255);
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);

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

}[/code]```