xxxxxxxxxx
109
let mpFont;
let photo;
let gameState = 'start';
function preload() {
mpFont = loadFont('MPFont.ttf');
photo = loadImage("Goomba.png");
}
function startScreen(){
let from = color(255, 135, 0);
let to = color(0, 240, 255);
let interA = lerpColor(from, to, 0);
background(interA);
noStroke();
for (let i = 0; i < 664; i = i + 6.64){
fill(lerpColor(from, to, 0 + i * 0.0015))
rect(0, i, 820, 7);
}
fill(200);
strokeWeight(4);
rect(15, 95, 785, 555, 20);
fill('#ED225D');
textFont(mpFont);
textSize(100);
text('Goomba Spotting', 60, 80)
textSize(50);
text('Goombas have invaded NYUAD!', 25, 130);
text('You two have been hired as', 25, 170);
text('Goomba Spotters to assist with', 25, 210);
text('the resistance effort.', 25, 250);
text('Your task: To count the exact', 25, 290);
text('number of Goombas that pass by.', 25, 330);
text('A last-minute refresher!', 25, 370);
text('Goombas look like:', 25, 430);
text('Tap once for each Goomba you see!', 25, 490);
text('Player 1: Tap on the A key!', 25, 530);
text('Player 2: Tap on the L key!', 25, 570);
text('Good luck, Spotters.', 25, 630);
image(photo, 420, 380, 58.8, 70);
strokeWeight(4);
rect(610, 510, 190, 140, 20);
fill(0);
text('START!', 615, 595);
}
function endScreen(){
let from = color(255, 135, 0);
let to = color(0, 240, 255);
let interA = lerpColor(from, to, 0);
background(interA);
noStroke();
for (let i = 0; i < 664; i = i + 6.64){
fill(lerpColor(from, to, 0 + i * 0.0015))
rect(0, i, 820, 7);
}
fill(200);
strokeWeight(4);
rect(15, 95, 785, 555, 20);
fill('#ED225D');
textFont(mpFont);
textSize(100);
text('Results', 250, 80)
textSize(50);
text("Okay, let's see here.", 25, 130);
text('Player 1.', 25, 170);
text('You counted Goombas.', 25, 210);
text('Player 2.', 25, 250);
text('You counted Goombas.', 25, 290);
text('There were N Goombas.', 25, 350);
text('Player, great work!', 25, 410);
text('Player, see me in my office.', 25, 450);
text('PLAYER WINS!', 25, 490);
strokeWeight(4);
rect(610, 510, 190, 140, 20);
fill(0);
textSize(39);
text('RESTART!', 613, 595);
}
function setup() {
createCanvas(820, 664);
}
function draw() {
if (gameState == 'start') {
startScreen();
} else if (gameState == 'playing') {
gameScreen();
} else if (gameState == 'end') {
endScreen();
}
}
function mousePressed() {
if (gameState == 'start') {
if (610 < mouseX && mouseX < 800 && 510 < mouseY && mouseY < 650){
gameState = 'end';
}
} else if (gameState == 'playing'){
if (610 < mouseX && mouseX < 800 && 510 < mouseY && mouseY < 650){
gameState = 'start';
}
} else if (gameState == 'end'){
if (610 < mouseX && mouseX < 800 && 510 < mouseY && mouseY < 650){
gameState = 'start';
}
}
}