xxxxxxxxxx
89
let xs = 200;
let ys = 0;
let ysjump = 2;
let ws = 10;
let hs = 20;
let xp = 185;
let yp = 0;
let wp = 20;
let hp = 800;
let xl = 175;
let xxl = 220;
let wl = 40;
let hl = 10;
let xg = 0;
let yg = 300;
let smn = 75;
let yr = 0;
let yrjump = 1;
let wr = 5;
let hr = 15;
function setup() {
createCanvas(400, 400);
colorMode(HSB);
}
function draw() {
//sky
background(190, 30, 100);
if (mouseIsPressed) {
rain();
}
//seed
fill(0);
ellipse(xs, ys, ws, hs);
ys = ys + ysjump;
if (ys >= height) {
background(
//H - S - B
map(mouseX, 0, width, 190, 200),
map(mouseX, 0, width, 30, 80),
map(mouseX, 0, width, 100, 44)
);
//sun -> moon
fill(
map(mouseX, 0, width, 50, 60),
map(mouseX, 0, width, 30, 0),
map(mouseX, 0, width, 100, 90)
);
noStroke();
ellipse(mouseX, smn, smn, smn);
//plant
fill(140, 44, 48);
stroke(140, 44, 48);
rect(xp, yp, wp, hp);
//leaves
for (let yl = 50; yl < height; yl = yl + 60) {
fill(140, 44, 48);
stroke(0);
ellipse(xl, yl, wl, hl);
ellipse(xxl, yl, wl, hl);
}
}
//ground
fill(12, 92, 14);
rect(xg, yg, width, height / 4);
}
function rain() {
for (let xr = 0; xr <= width; xr = xr + 20) {
noStroke();
fill(184, 54, 60)
ellipse(xr, yr, wr, hr)
yr = yr + yrjump;
if (yr > height) {
yr = 0;
}
}
}