xxxxxxxxxx
142
let x = 130;
let y = 120;
let x2 = 210;
let y2 = 120;
let x3 = 110;
let y3 = 220;
let col1 = 0;
let bub1 = 0;
function setup() {
createCanvas(400, 400);
}
function bob() {
//body
fill (255,255,0);
square(100, 50, 190);
//left eye
fill (255,255,255);
rect(130, 100, 50, 50);
//left pupil
fill (27,147,255);
rect(x, y, 20, 20);
if (x < 160) {
x = x +1;
}
//right eye
fill (255,255,255);
rect(210, 100, 50, 50);
//right pupil
fill (27,147,255);
rect(x2, y2, 20, 20);
if (x2 < 240) {
x2 = x2 +1;
}
//nose
fill (255,255,0);
rect(200, 160, 50,20);
//left tooth
fill (255,255,255);
rect(170, 200, 20, 20);
//right tooth
fill (255,255,255);
rect(195, 200, 20, 20);
//white shirt
fill (255,255,255);
rect(100, 240, 190, 30);
//left sleeve
fill (255,255,255);
rect(80, 240, 20, 30);
//left arm
fill (255,255,0);
rect(80, 270, 20, 40);
//right sleeve
fill (255,255,255);
rect(290, 240, 20, 30);
//right arm
fill (255,255,0);
rect(290, 270, 20, 40);
//red tie
fill (255,0,0);
rect(185, 240, 20, 20);
//brown pants
fill (146,84,59);
rect(100, 270, 190, 30);
//left pant leg
fill (146,84,59);
rect(120, 300, 50, 30);
//left leg
fill (255,255,0);
rect(135, 330, 20, 30);
//left shoe
fill (0,0,0);
rect(125, 360, 30, 20);
//right pant leg
fill (146,84,59);
rect(215, 300, 50, 30);
//right leg
fill (255,255,0);
rect(230, 330, 20, 30);
//right shoe
fill (0,0,0);
rect(230, 360, 30, 20);
};
function jellyfish(startingColour){
//jellyfish
fill (startingColour,20,255);
rect(330, 110, 30,40);
fill (startingColour,150,255);
rect(350, 120, 5, 5);
fill (startingColour,150,255);
rect(345, 110, 5, 5);
fill (startingColour,150,255);
rect(335, 115, 5, 5);
translate(345, 150);
rotate(frameCount*1.6);
fill (startingColour,20,255)
rect(0, 0, 30, 10);
}
jellyColour = 255;
function draw() {
background(220);
bob();
jellyfish(jellyColour); // optional I'm passing a colour to account for the red value. and in the jellyfish function I can change it
jellyColour = random(0,255);
}