xxxxxxxxxx
69
let lineY = [];
let lineSpeed = [];
function setup() {
createCanvas(300, 300);
for (let i = 0; i < 100; i++) {
lineY[i] = random(height);
lineSpeed[i] = random(8,10);
}
}
function draw() {
background(32,42,68);
//hills
fill(118, 136, 106)
grassHill = circle(90, 330, 300)
grassHill2 = circle(220, 370, 300)
//draw house
noStroke()
drawHouse(230, 195, 100, 100, [84,7,7], [0,0,0], [254,222,23], [214,183,152]);
//rain
for (let i = 0; i < lineY.length; i++) {
let lineX = width * i / lineY.length;
stroke(187,205,212);
strokeWeight(2)
line(lineX, lineY[i], lineX, lineY[i]+4);
lineY[i] += lineSpeed[i];
if (lineY[i] > height) {
lineY[i] = 0;
}
}
function drawHouse(squareX, squareY, wide, high, color1, color2, color3, color4) {
let houseDistance = wide / 2;
// main square of house
fill(color1);
rect(squareX - houseDistance, squareY - houseDistance, wide, high);
// roof
fill(color2);
triangle(squareX-wide/2, squareY-high/2, squareX, squareY-high, squareX+houseDistance, squareY-high/2)
// chimney
fill(color1);
rect(squareX+high/10, squareY-high, houseDistance/3, high/3)
// windows
fill(color3);
rect(squareX+high/10, squareY-high/3, houseDistance/2, high/4)
rect(squareX-high/3, squareY-high/3, houseDistance/2, high/4)
// door
fill(color4);
rect(squareX-high/9, squareY+high/6, houseDistance/2, high/3)
// doorknob
fill(color1);
circle(squareX+high/10, squareY+high/3, wide/25)
}
}