xxxxxxxxxx
boolean [][] squarePhil;
int randColor;
int randW;
int randH;
void setup(){
size(800,800,P2D);
background(255);
squarePhil = new boolean[height/20][width/20];
for(int r = 0; r < 20; r ++){
for(int c = 0; c < 20; c ++){
strokeWeight(5);
fill(255);
rect(r*40,c*40,40,40);
}
}
//noLoop();
}
void draw(){
for(int r = 0; r < 20; r ++){
for(int c = 0; c < 20; c ++){
randColor = int(random(7));
randW = int(random(5));
randH = int(random(5));
strokeWeight(5);
if(randColor == 0){
fill(255,0,0);
}
else if(randColor == 1){
fill(0,0,255);
}
else if(randColor == 2){
fill(255,255,0);
}
else if(randColor == 3){
fill(0);
}
else{
fill(255);
}
while(squarePhil[r][c]){
c ++;
if(c == 20)
break;
}
rect(r*40, c*40, 40*randW, 40*randH);
for(int w = 0; w <= randW; w ++){
for(int h = 0; h <= randH; h ++){
squarePhil[r+w][c+h] = true;
}
}
}
}
squarePhil = new boolean [height/20][width/20];
delay(1);
}