class Building {
float h;
float w;
int x1,y1,x2,y2;
int [] win;
color window_color;
Building (int tx1, int ty1, int tx2, int ty2) {
w= (tx2-tx1);
h= (ty2-ty1);
x1= tx1;
y1= ty1;
x2= tx2;
y2= ty2;
window();
}
void display() {
fill(0);
rectMode(CORNERS);
rect(x1,y1,x2,y2);
println(x1+" "+y1+" "+x2+" "+y2);
rectMode(CORNER);
}
void window() {
win =new int[4];
win[0]= int(random(x1+5,x2-15));
win[1]=int(random(x1+5,x2-15));
win[2]=int(random(x1+15,x2-15));
win[3]= int(random(x1+15,x2-15));
// rect(int (random(x1+5,x2-15)), y1+5,10,10);
//rect(int(random(x1+5,x2-15)), y1+25,10,10);
//rect(int(random(x1+15,x2-15)), y1+45,10,10);
// rect(int(random(x1+15,x2-15)), y1+65,10,10);
}
void window_display( color c) {
fill(c);
rect(win[0],y1+5,10,10);
rect(win[1],y1+25,10,10);
rect(win[2], y1+45,10,10);
rect(win[3], y1+65, 10,10);
}
}//class ends here
Building [] r;
color window_color;
color sky;
void setup() {
size(800,300);
background (255);
smooth();
noStroke();
fill(255);
//for sun
x =100;
y = 70;
r= new Building [15];
for (int i=0; i<15; i++) {
r[i]= new Building(i*60, int (height-random(50,120)), int (i*60+random(40,70)), height);
}
window_color = color(255);
sky=color(255);
cloud= loadImage ("cloud.png");
}
void draw() {
background (sky);
fill(255,255,0);
ellipse(x,y, 100,100);
for (int i=0; i<15; i++) {
r[i].display();
r[i].window_display(window_color);
//this is how you control the switch depending where your mouse(sun) is
if (x < width/2) {
println("morning");
sky=color(#ffffff);
window_color = color(255);
//clouds
pushMatrix();
scale (0.15);
image (cloud, 1500,100);
scale (1.5);
image (cloud, 2000, 150);
popMatrix();
}
else {
println("evening");
sky=color(#375389);
window_color = color(255,255,0);
for (int j = 0; j < width; j+=800) {
stroke(255,255,0);
strokeWeight(2);
point(random(0,800),random(0,200));
/*point (100,100);
point (200,90);
point (400,50);
point (550,120);*/
}
noStroke();
}
}
}