xxxxxxxxxx
73
var x, y;
var up, right;
var speed_x, speed_y;
function setup() {
createCanvas(400, 400);
x = width / 2 - 70;
y = height / 2 - 50;
up = true;
right = true;
speed_x = 4;
speed_y = 2;
}
function draw() {
background('#F5C397');
// hair
strokeWeight(0);
fill("#56330f");
ellipse(x - 30, y - 120, x + 130, y);
ellipse(x + 190, y - 130, x + 120, y - 50);
strokeWeight(3);
// eye white
fill(255);
ellipse(x, y, 90, 50);
ellipse(x + 150, y, 90, 50);
// eye iris
fill("#654321");
ellipse(x, y, 50, 50);
ellipse(x + 150, y, 50, 50);
// eye pupil
fill(0);
ellipse(x, y, 20, 20);
ellipse(x + 150, y, 20, 20);
//eye white in pupil
fill(255);
ellipse(x - 5, y - 5, 10, 10);
ellipse(x + 145, y - 5, 10, 10);
// nose
fill(0);
ellipse(x + 100, y + 80, 20, 10);
ellipse(x + 55, y + 80, 20, 10);
// tongue
strokeWeight(5);
line(x + 54, y + 140, x + 102, y + 140);
strokeWeight(3);
fill("#d62270");
arc(x + 78, y + 140, 50, 100, 0, PI);
// boundaries
if (x > 205)
right = false
if (x < 45)
right = true;
if (y < 25)
up = false
if (y > 210)
up = true
// moving
x += right ? speed_x: -speed_x;
y += up ? -speed_y: speed_y;
}