$~make it rain~$

Rain r1;

int raindrops = 50;
int checkWeather;
int whichWeather;

Rain[] drops = new Rain[raindrops]; // Declare and create the array

void setup() {
  size(600, 600);
  background(255);
  smooth();
  noStroke();

  //Loop through array to create each object
  for (int i = 0; i < drops.length; i++) {
    drops[i] = new Rain(); // Create each object
    r1 = new Rain();
  }
}

void draw() {
  fill(255, 50);
  rect(0, 0, 600, 600);
  for (int i = 0; i < drops.length; i++) {
    drops[i].fall();
  }
  if (checkWeather == 1) {
    background(184, 232, 252);
    fill(255, 255, 0);
    noStroke();
    ellipse(500, 100, 100, 100);
  }
}

void keyPressed() {
  checkWeather = 1;
}

void keyReleased() {
  checkWeather = 0;
}

class Rain {
  float x = random(600);
  float y = random(-height);

  void fall() {
    y = y + 10;
    fill(176, 227, 255, 100);
    ellipse(x, y, 10, 10);

    if (y>height) {
      x = random(600);
      y = random(-200);
    }
  }
}

 

VIDEO

 

 

One thought on “$~make it rain~$

  1. I really like this as a screen saver idea. If the user went AFK and then the screen started to rain, that made me weirdly personify the computer by thinking that said rain represented its crying. And when you come back, keypress/etc and it’s sunny (so the computer’s happy!)

Leave a Reply