xxxxxxxxxx
55
let ySunPosition = 300;
const ySunEnd = 300;
function setup() {
createCanvas(600, 600);
ySunPosition = height;
//background("blue");
}
function draw() {
background("blue");
if(ySunPosition > ySunEnd){
noStroke();
let rectHeight = 100;
fill('yellow');
rect(0, 300, 600, rectHeight);
fill('orange');
rect(0, 400, 600, rectHeight);
fill("red");
// rect(x, y, width, height)
rect(0, 500, 600, rectHeight);
}else{
// sun has risen, draw grass
fill('green');
rect(0, 550, 600, 50);
fill('lightgray');
ellipse(80, 50, 180, 50);
//ellipse(300, 100, 140, 50);
ellipse(470, 80, 180, 60);
}
stroke('black')
fill("yellow");
circle(300,ySunPosition,150);
fill('orange');
circle(300,ySunPosition,100);
if(ySunPosition > ySunEnd){
ySunPosition = ySunPosition - 1;
}
print("ySunPosition=", ySunPosition);
}