xxxxxxxxxx
96
let bodyw = 110;
let bodyh = 600;
let facew = 60;
let faceh = 90;
let y = 250;
let yjump = 4;
function setup() {
createCanvas(400, 400);
background(220);
}
function draw() {
rectMode(CENTER);
fill(0);
rect(width / 2, height, bodyw, bodyh, bodyw / 2);
fill(255);
rect(width / 2, height / 2.5, facew, faceh, facew / 2);
//face lines?
stroke(150,150,220);
strokeWeight(5);
line(185, 180, 185, 140);
line(215, 180, 215, 140);
//'mouth'
stroke(0);
line(195, 195, 205, 195);
//eyes
strokeWeight(3);
stroke(255);
fill(0);
ellipse(185, 160, 20, 10);
ellipse(215, 160, 20, 10);
noStroke();
if (mouseX > 150 && mouseX < 250) {
fill(225, 0, 0);
rect(200, 250, 60, 30, 10);
fill(225);
rect(180, 257, 10, 10, 3);
rect(200, 257, 10, 10, 3);
rect(220, 257, 10, 10, 3);
}
//use a for loop to add a row of teeth
//loop wont work
if (mouseIsPressed && mouseX > 150 && mouseX < 250) {
fill(0);
rect(200, 250, 60, 30, 10);
fill(225, 0, 0);
rect(200,random(245,250), 60, 30, 10);
fill(225);
rect(180, random(254,257), 10, 10, 3);
rect(200, random(254,257), 10, 10, 3);
rect(220, random(254,257), 10, 10, 3);
frog(y);
y = y + yjump;
}
}
function frog() {
//feet
// stroke(5,200,5);
fill(0, 225, 0);
rect(170, y, 30, 30, 10);
rect(230, y, 30, 30, 10);
ellipse(160, y + 10, 25, 10);
ellipse(240, y + 10, 25, 10);
ellipse(160, y + 35, 20, 10);
ellipse(240, y + 35, 20, 10);
//body
stroke(90, 150, 225);
fill(120, 180, 220);
ellipse(200, y + 15, 90, 50);
//head
noStroke();
fill(0, 225, 0);
ellipse(200, y + 30, 60, 35);
//eyes
fill(225)
ellipse(185, y + 20, 15, 10);
ellipse(215, y + 20, 15, 10);
fill(0)
ellipse(185, y + 24, 5, 5);
ellipse(215, y + 24, 5, 5);
//mouth
ellipseMode(CENTER);
ellipse(200, y + 42, 15, 8);
if (y > height) {
y = 250;
}
}