xxxxxxxxxx
40
let houseColor = 80;
let houseWidth = 300;
let houseHeight = 300;
function setup() {
createCanvas(500, 500);
}
function draw() {
// sky
background(0, 0, 255);
// grass
rectMode(CENTER);
fill(0, 255, 0);
rect(250, 400, 500, 200);
// house
fill(175, houseColor, 25);
rect(250, 250, houseWidth, houseHeight);
// roof
fill(125);
triangle((500-houseWidth)/2, (500-houseHeight)/2, 250, 50, houseWidth+(500-houseWidth)/2, (500-houseHeight)/2);
// door
fill(255, 0, 0);
rect(250, 250+(houseHeight/3), houseWidth/5, houseHeight/3);
// windows
fill(255, 255, 0);
rect(250-houseWidth/4, 250-houseWidth/4+20, houseWidth/4);
rect(250+houseWidth/4, 250-houseWidth/4+20, houseWidth/4);
}
function mousePressed() {
houseColor = random(80, 200);
houseWidth = random(250, 350);
houseHeight = random(250, 375);
}