xxxxxxxxxx
117
let circleY=[50,100,150,20];
function setup() {
createCanvas(400, 400);
}
function draw() {
background('#D6F3F7');
// ground
fill('#795548');
stroke('#6CB853');
strokeWeight(5);
rect(-5,390,500,50);
// tree trunk
fill('#795548');
noStroke();
rect(150,height/2,100,200);
//apples falling
for (let i=0; i<5; i++){
let circleX=50 * (i+1);
fill('#F44336');
noStroke();
strokeWeight(5);
circle(circleX,circleY[i],35);
circleY[i]++;
if (circleY[i]>height){
circleY[i]=0
}
}
// leaves
for (let x=0; x<=width; x+=35){
for (let y=0; y<=height; y+=50){
fill('#4CAF50');
strokeWeight(5);
stroke('#54AF4C');
circle(x,y/2,40);
}
}
// apples
if (mouseY<200 && mouseX<200){
fill('#F44336');
noStroke();
circle(100,100,40);
circle(150,150,30);
circle(50,120,30);
}
else if (mouseY<200 && mouseX>200){
fill('#F44336');
noStroke();
circle(260,100,30);
circle(300,160,30);
circle(350,100,40);
}
// mouse pressed
if (mouseIsPressed){
background('#D4E7E7');
// ground.2
fill('#66463A');
stroke('#B3A769');
strokeWeight(5);
rect(-5,390,500,50);
// tree trunk.2
fill('#66463A');
noStroke();
rect(150,height/2,100,200);
// leaves falling
for (let i=0; i<5; i++){
let circleX=50 * (i+1);
fill('#FF8500');
noStroke();
circle(circleX,circleY[i],30);
circleY[i]++;
if (circleY[i]>height){
circleY[i]=0
}
}
// leaves.2
for (let x=0; x<=width; x+=35){
for (let y=0; y<=height; y+=50){
fill('#FA8607');
strokeWeight(5);
stroke('#FF8500');
circle(x,y/2,40);
}
}
// apple turned to leaves
if (mouseY<200 && mouseX<200){
fill('#FF9800');
noStroke();
circle(100,100,40);
circle(150,150,30);
circle(50,120,30);
}
else if (mouseY<200 && mouseX>200){
fill('#EC7D05');
noStroke();
circle(260,100,30);
circle(300,160,30);
circle(350,100,40);
}
}
}