xxxxxxxxxx
45
var mouth = 0, down = false, x = -40;
function setup() {
createCanvas(800, 400);
noStroke();
frameRate(60);
}
function draw() {
background(220, 100, 100);
fill(255);
ellipse(40 + x, height/2, 40);
x+=3;
if(x >= width/2){
x = -40;
}
ellipseMode(RADIUS);
fill(255, 255, 0);
ellipse(width/2, height/2, 200);
fill(220, 100, 100);
beginShape();
vertex(200, height/2);
vertex(200, height/2 - mouth);
vertex(width/2, height/2);
vertex(200, height/2 + mouth);
endShape(CLOSE);
noStroke();
if(down){
mouth-=10;
}else{
mouth+=10;
}
if(mouth >= 200){
down = true;
}else if(mouth <= 0){
down = false;
}
}