Mouse click changes the outfit to green, WASD moves character around.
xxxxxxxxxx
let head_x
let head_y
let text_p1
let page_number = 1;
function setup() {
createCanvas(600, 400);
textAlign (CENTER);
head_x = 35
head_y = 280
let text_p1 = "GAME OVER";}
function draw() {
background(135, 206, 235);
/// sky
fill (224, 255, 255);
ellipse (10, 30, 400, 110);
ellipse (10, 150, 200, 50);
ellipse (600, 10, 400, 100);
ellipse (600, 70, 250, 50);
// clouds in sky
fill (255, 215, 0);
rect (10, 220, 110, 135, 50);
rect (200, 250, 70, 135, 45);
rect (415, 210, 70, 135, 45);
rect (300, 180, 130, 155, 60);
// yellow hills in background
fill (0, 128, 0);
ellipse (500, 380, 1400, 200)
// green bushes in background
fill (154, 205, 50);
rect (0, 380, 600, 20);
// green grass
fill (0);
square (520, 120, 60);
fill (160, 82, 45);
rect (520, 118, 28, 20);
rect (520, 140, 15, 20);
rect (520, 162, 28, 18);
rect (550, 162, 30, 18);
rect (550, 118, 30, 20);
rect (537, 140, 25, 20);
rect (563, 140, 17, 20);
/// third brown block
fill (255, 215, 0);
square (460, 120, 60);
fill (100, 100, 100);
circle (465, 125, 5);
circle (465, 175, 5);
circle (515, 125, 5);
circle (515, 175, 5);
fill (255);
square (482, 160, 15);
rect (482, 125, 15, 30);
/// second golden block
fill (0);
square (400, 120, 60);
fill (160, 82, 45);
rect (400, 118, 28, 20);
rect (400, 140, 15, 20);
rect (400, 162, 28, 18);
rect (430, 162, 30, 18);
rect (430, 118, 30, 20);
rect (417, 140, 25, 20);
rect (443, 140, 17, 20);
/// first brown block
fill (34, 150, 34);
rect (80, 340, 80, 40);
rect (70, 315, 100, 40, 10);
rect (450, 290, 80, 90);
rect (440, 250, 100, 40, 10);
/// green pipes
fill (255, 215, 0);
ellipse (90, 100, 40, 60);
ellipse (150, 100, 40, 60);
ellipse (210, 50, 40, 60);
ellipse (90, 100, 35, 55);
ellipse (150, 100, 35, 55);
ellipse (210, 50, 35, 55);
rect (85, 88, 5, 30);
rect (145, 88, 5, 30);
rect (205, 38, 5, 30);
/// coins
fill (250);
arc(133, 200, 100, 70, 0, PI + QUARTER_PI, PIE);
fill (178, 34, 34);
arc(130, 210, 100, 90, 0, PI + QUARTER_PI, PIE);
fill (0, 128, 0);
rect (115, 255, 10, 60);
fill (250);
circle (100, 210, 15);
circle (110, 230, 10);
circle (150, 220, 15);
circle (130, 240, 20);
/// monster flower
if (mouseIsPressed === true) {
fill (34, 139, 34);
} else {
fill (160, 0, 0);
}
rect (head_x-15, head_y+20, 30, 50);
fill (head_x+76, head_y-137, 175);
rect (head_x-15, head_y+70, 10, 30);
rect (head_x+5, head_y+70, 10, 30);
fill (head_x+104, head_y-211, 19);
circle (head_x, head_y, 50);
/// character
if (page_number == 1){
text(text_p1, 200, 210);
}
}
function keyPressed(){
if (key == 'w'){
head_x -= 1
head_y -= 1
}
if (key == 's'){
head_x += 1
head_y += 1
}
if (key == 'a'){
head_x -= 3
head_y -= 3
}
if (key == 'd'){
head_x += 3
head_y += 3
}
}