xxxxxxxxxx
33
let sunY = 350;
let vSpeed = -1;
let counter = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background('blue');
fill('yellow');
ellipse(width / 2, sunY, 100);
fill('green');
rect(0, 300, width, 100);
sunY = sunY + vSpeed;
// If 250 frames have passed
if (counter == 250) {
// Stop moving the sun
vSpeed = 0;
}
// I
if (counter == 250 + 120) {
vSpeed = 1;
}
if (counter == 250 + 120 + 250) {
vSpeed = 0;
}
if (counter == 740) {
vSpeed = -1;
counter = 0;
}
counter = counter + 1;
}