xxxxxxxxxx
82
//loops
function setup() {
createCanvas(400, 400);
w = 255; //window color
back = 255; //background color
}
function draw() {
background(back);
//building outlines
fill("blue");
rect(25, 125, 130, 300);
fill("red");
rect(200, 75, 150, 325);
//window loop
for (var i = 3; i < 8; i++) {
y = i * 50;
h = 120 + (i - 3) * 60;
fill(w);
// left side of building one
rect(50, y, 30, 30);
line(50, y + 15, 80, y + 15);
line(65, y, 65, y + 30);
// right side of building one
rect(100, y, 30, 30);
line(100, y + 15, 130, y + 15);
line(115, y, 115, y + 30);
// left side of building two
circle(245, h, 40);
quad(245, h - 15, 260, h, 245, h + 15, 230, h);
line(245, h - 20, 245, h - 15);
line(260, h, 265, h);
line(245, h + 20, 245, h + 15);
line(225, h, 230, h);
//right side of buildin two
circle(300, h, 40);
quad(300, h - 15, 315, h, 300, h + 15, 285, h);
line(300, h - 20, 300, h - 15);
line(315, h, 320, h);
line(300, h + 20, 300, h + 15);
line(280, h, 285, h);
}
//change from night to day
if (mouseX > 200) {
back = 0;
w = "yellow";
//moon
fill(226)
circle(76,50,60)
fill(0)
circle(90,50,48)
} else if(mouseX <= 200){
back = ("#29A8F2")
w = 255
//sun
fill("#F2C329")
circle(76,50,60)
}
}