xxxxxxxxxx
122
let img;
let xspeed = 3;
let yspeed = 4;
let x = 200;
let y = 200;
function setup() {
createCanvas(400, 600);
}
function preload() {
img = loadImage('IMG_3672 body .jpg');
}
function draw() {
background(0);
stroke(255);
//line(0, 200, 400, 200);
//line(0, 400, 400, 400);
//body
image(img, 85, 200);
//lower limbs
//legs
noStroke();
fill(200);
rect(190, 400, 20, 20);
fill(0);
stroke(200);
strokeWeight(3);
ellipse(160, 410, 60, 20);
ellipse(240, 410, 60, 20);
ellipse(140, 425, 10, 10);
ellipse(260, 425, 10, 10);
//thigh
push();
translate(150, -50);
rotate(PI / 10);
rect(250, 430, 7, 65);
pop();
push();
translate(-130, 73);
rotate(-PI / 10);
rect(145, 430, 7, 65);
pop();
//kneel
ellipse(165, 508, 10, 5);
ellipse(235, 508, 10, 5);
//shank
push();
translate(-130, 73);
rotate(-PI / 10);
rect(210, 535, 5, 45);
pop();
push();
translate(150, -50);
rotate(PI / 10);
rect(185, 535, 5, 45);
pop();
//feet
triangle(140, 570, 145, 560, 180, 570);
triangle(260, 570, 255, 560, 220, 570);
//head
noStroke();
fill(252, 232, 14);
ellipse(x - 40, y - 10, 20, 20);
rect(x - 45, y - 35, 10, 18, 3);
noStroke();
fill(208, 31, 64);
rect(x - 40, y - 40, 80, 40, 10);
fill(172, 163, 208);
rect(x - 30, y - 40, 60, 40, 5);
stroke(0);
strokeWeight(1);
fill(255);
ellipse(x, y - 15, 40, 20);
line(x - 10, y - 24, x - 10, y - 6);
line(x, y - 24, x, 194);
line(x + 10, y - 24, x + 10, y - 6);
push();
noStroke();
fill(38, 25, 73);
triangle(x - 70, y - 60, x, y - 50, x, y - 10);
triangle(x, y - 10, x, y - 50, x + 70, y - 60);
pop();
noStroke();
fill(252, 232, 14);
quad(x - 20, y - 65, x - 5, y - 45, x + 20, y - 35, x + 5, y - 55);
quad(x + 20, y - 65, x + 5, y - 45, x - 20, y - 35, x - 5, y - 55);
if (mouseY <= 200) {
head();
} else if (mouseY >= 200 || mouseY < 400) {
body();
}
//switch () {
// case ():
// break;
//}
}
function head() {
if (x > 380 || x < 20) {
xspeed *= -1;
}
x += xspeed;
if (y > 600 || y < 0) {
yspeed = -yspeed;
}
y += yspeed;
}
function body() {
xspeed = 0;
yspeed = 0;
x = 200;
y = 200;
}