// SIMONE ROTH - PS 3 # 4 //
Square[] square = new Square[50];
void setup() {
size(500, 500);
smooth();
background(240);
noStroke();
for (int i=0; i < square.length; i++) {
square[i] = new Square(width/2, height/2, 40, 40);
}
}
void draw() {
for (int i=0; i < square.length; i++) {
square[i].display();
}
}
// SIMONE ROTH - PS 3 # 4 //
class Square {
float btnX;
float btnY;
float btnW;
float btnH;
float speed;
Square(float btnX, float btnY, float btnW, float btnH) {
this.btnX=btnX;
this.btnY=btnY;
this.btnW=btnW;
this.btnH=btnH;
this.speed=random(2, 5);
}
void display() {
int space = 30;
for (int i=0; i < 10; i = i+4) {
float x = space + i * space;
float y = width/2;
float length = (i+1) * (mouseX/30);
btnX+=random(-speed, speed);
btnY+=random(-speed, speed);
rect(btnX, btnY, btnW, btnH);
}
fill(#e83698);
}
}