// Global Variables
int length = 50; // change this to a larger number
int[] xCoordinate = new int[length];
int[] yCoordinate = new int[length];
float[] yvel = new float[length];
int[] widths = new int[length];
int[] heights = new int[length];
float[] hues = new float[length];
// create a new float array called xvel and give it a length of length
void setup(){
size(800, 600);
for (int i = 0; i < length; i++) {
xCoordinate[i] = (int) random(0, width);
yCoordinate[i] = (int) random(0, height);
widths[i] = (int) random(10, 20);
heights[i] = (int) random(20, 30);
hues[i] = random(150, 170);
}
calculateSpeeds();
colorMode(HSB);
}
void draw(){
background(0);
for (int i = 0; i < length; i++) {
fill(hues[i], 200, 200);
ellipse(xCoordinate[i], yCoordinate[i], widths[i], heights[i]);
yCoordinate[i] += yvel[i];
// add xvel[i] to xCoordinate[i]
}
respawnRaindrops();
}
void respawnRaindrops() {
for (int i = 0; i < length; i++) {
if (yCoordinate[i] > height) {
yCoordinate[i] = -8;
// set each value of the xCoordinate array to a random number
// between 0 and the width of the canvas
}
}
}
void calculateSpeeds() {
for (int i = 0; i < length; i++) {
float totalSize = 0;
totalSize += widths[i];
totalSize += heights[i];
yvel[i] = totalSize/3;
// set each value of the xvel array to a random number between -3 and 3
}
}