xxxxxxxxxx
75
let x1, x2, y;
function setup() {
createCanvas(400, 400);
x1 = 170;
x2 = 230;
y = 150;
}
function draw() {
background(120, 190, 255);
//grass
fill(80, 200, 10);
rect(0, 350, 400, 50);
//body
fill(10, 180, 200);
strokeWeight(1);
ellipse(200, 300, 130, 250);
//arms
strokeWeight(5);
line(135, 280, mouseX-100, mouseY);
line(265, 280, mouseX+100, mouseY);
//face
fill(255);
strokeWeight(1);
ellipse(200, 150, 140, 150);
//glasses
fill(255);
strokeWeight(2);
circle(170, 150, 50);
circle(230, 150, 50);
line(194, 150, 206, 150);
line(134, 130, 145, 150);
line(268, 130, 255, 150);
//eyes
fill(0);
ellipse(x1, y, 10, 20);
ellipse(x2, y, 10, 20);
//left eye
if ((mouseX>160) && (mouseX<180)) {
x1 = mouseX;
}
//right eye
if ((mouseX>215) && (mouseX<245)) {
x2 = mouseX;
}
//updown eye movement
if ((mouseY>130) && (mouseY<165)){
y = mouseY;
}
//smile
strokeWeight(1);
fill(150, 0, 0);
arc(200, 195, 20, 20, 0, PI);
//cap
strokeWeight(2);
fill(255, 120, 0);
ellipse(270, 100, 80, 20);
arc(200, 110, 120, 120, PI, 0, CHORD);
//pocket
strokeWeight(1);
fill(20, 150, 200);
square(200, 250, 45, 0, 0, 10, 10);
}