xxxxxxxxxx
float[]circle_x = new float [200];
float[]circle_y = new float [200];
float[]circle_speed_x = new float [200];
float[]circle_speed_y = new float [200];
float[]color_a= new float [200];
float[]color_b= new float [200];
float[]color_c= new float [200];
void setup() {
size(500, 500);
for(int i=0; i<200; i=i+1){
circle_x[i] = random(width);
circle_y[i] = random(height);
circle_speed_x[i] = random(6.0);
circle_speed_y[i] = random(6);
color_a[i]= random(400);
color_b[i]= random(400);
color_c[i]= random(400);
}
}
void draw(){
background(0);
for (int i = 0; i<200; i++){
circle_x[i] = circle_x[i] + circle_speed_x[i];
circle_y[i] = circle_y[i] + circle_speed_y[i];
noStroke();
fill(random(color_a[i]), random(color_b[i]), random(color_c[i]));
rect(circle_x[i], circle_y[i], 15, 15);
if (circle_y[i] < 0){
circle_speed_y[i] = 14;
}
if (circle_y[i] > height){
circle_speed_y[i] = -2;
}
if (circle_y[i] < 0){
circle_speed_x[i] = 14;
}
if (circle_x[i] > width){
circle_speed_x[i] = -14;
}
}
}
void mousePressed(){
for(int i = 0; i < 200; i++){
circle_x[i] = mouseX;
circle_y[i] = mouseY;
circle_speed_x[i]=random (10.0);
color_a[i] = random(300);
color_b[i] = random(300);
color_b[i] = random(300);
circle_speed_y[i]=random (10);
}
}