xxxxxxxxxx
//global variable space
let speed;
let b1x=190;
let b2x=245;
let b3x=260;
let b4x=230;
let b5x=255;
let b6x=260;
let b1y=135;
let b2y=100;
let cx1=0;
let cx2=0;
let cx3=0;
let cx4=0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(400);
background (52, 201, 235);
drawClouds();
drawBushes();
drawTree();
drawSun();
drawButterfly();
}
function mousePressed(){
speed=random(-2,3);
}
//custom functions and definitions
function drawClouds(){
fill(255);
noStroke();
circle(50+cx1,85,28);
circle(70+cx1,80,30);
circle(55+cx1,100,30);
circle(35+cx1,95,30);
circle(75+cx1,95,30);
circle(85+cx1,85,30);
circle(200+cx2,40,28);
circle(215+cx2,45,28);
circle(210+cx2,65,28);
circle(190+cx2,58,28);
circle(230+cx2,68,28);
circle(235+cx2,50,28);
circle(95+cx3,160,35);
circle (110+cx3,175,30);
circle(90+cx3,190,30);
circle(75+cx3,170,30);
circle (70+cx3,190,30);
circle (340+cx4, 128, 35);
circle (320+cx4, 145, 35);
circle(350 +cx4, 155, 35);
circle(315 +cx4,120,35);
cx1 -= .3
cx2+=.3
cx3+=.3
cx4+=.3
if (cx1 < -90) {
cx1 = 0;
}
if(cx2 > 90){
cx2=4;
}
if(cx3> 90){
cx3=3;
}
if (cx4>90){
cx4=0;
}
}
function drawBushes(){
fill(94, 252, 3);
rect(300, 345,70, 55, 50, 15, 10, 5);
rect(180,345, 100, 55, 50, 15, 10, 5);
fill(252, 15, 3)
circle(200,370,10);
circle(200,390,10);
circle(230,395,10);
circle (245,360,10);
circle(250,385,10);
circle(220, 360,10);
fill(221, 25, 224)
circle(350,360,10);
circle(345, 380,10);
circle (330, 390, 10);
circle (320,360,10);
circle(310,380,10);
}
function drawTree(){
fill(89, 55, 0)
rect(90,340,50,70,20);
fill(94, 252, 3);
circle(115, 320, 75);
}
function drawSun (){fill(252, 248, 3);
noStroke()
circle(130,38, 60);
fill(252, 132, 3);
circle (130, 38, 30);
}
function drawButterfly(){
fill(252, 3, 165);
noStroke();
triangle (b1x,b1y, b2x, 150, b3x,200);
fill(252, 248, 3);
triangle(b4x,142,b5x,b2y,b6x,200);
b1x-=1;
b2x-=1;
b3x-=1;
b4x-=1;
b5x-=1;
b6x-=1;
b1y+=1;
b2y+=1;
if (b1y>138){
b1y-= 15;
}
if(b2y>103){
b2y-=15;
}
if( b1x<0){
b1x=400;
b2x=455;
b3x=470;
b4x=440;
b5x=465;
b6x=470;
}
//
}