xxxxxxxxxx
167
let myFont;
let bg, fridge1, fridge2, fridgeshelf, macncheese, bam;
let bgShow = false;
let fridgeOpen = false;
let shelfShow = false;
let showMacLabel = false;
let showBamLabel = false;
let actionFinished1 = false;
let actionFinished2 = false;
let actionFinished3 = false;
let viewedLabel1 = false;
let viewedLabel2 = false;
let questionState1 = false;
let questionState2 = false;
let questionState3 = false;
function setup() {
createCanvas(windowWidth, windowHeight);
soundtrack.loop();
textAlign(CENTER);
}
function preload() {
myFont = loadFont("PixelifySans-VariableFont_wght.ttf");
bg = loadImage("bg1.jpg");
fridge1 = loadImage("fridgeclosed.png");
fridge2 = loadImage("fridgeopen.png");
fridgeshelf = loadImage("fridgeshelf.png");
macncheese = loadImage("mac.png");
bam = loadImage("bamcan.png");
maclabel = loadImage("maclabel.png");
bamlabel = loadImage("bamlabel.png");
soundtrack = loadSound("soundtrack.mp3");
}
function draw() {
if (bgShow === true) {
background(bg);
} else {
background(0);
fill(255, 0, 0);
textFont(myFont);
textSize(100);
text("i'm hungry", windowWidth / 2, windowHeight / 2);
textSize(32);
text("click anywhere to start", windowWidth / 2, 600);
}
if (fridgeOpen === false && bgShow === true) {
image(fridge1, 550, 150, 350, 500);
actionFinished1 = true;
} else if (fridgeOpen === true && bgShow === true) {
image(fridge2, 550, 150, 350, 500);
actionFinished2 = true;
}
if (bgShow === true && shelfShow === true) {
background(fridgeshelf);
actionFinished3 = true;
image(macncheese, 400, 200, 300, 300);
image(bam, 700, 5, 275, 275);
}
if (shelfShow === true && showMacLabel === true) {
image(
maclabel,
windowWidth / 20,
windowHeight / 15,
windowWidth / 1.2,
windowHeight / .75
);
fill(255, 0, 0);
textFont(myFont);
textSize(60);
textSize(32);
text("press 'b' to go back", windowWidth / 2, windowHeight/1.1);
viewedLabel1 = true;
}
if (shelfShow === true && showBamLabel === true) {
image(
bamlabel,
windowWidth / 20,
windowHeight / 8,
windowWidth / 1.2,
windowHeight / 1.2
);
fill(255, 0, 0);
textFont(myFont);
textSize(60);
textSize(32);
text("press 'b' to go back", windowWidth / 2, windowHeight/1.2);
viewedLabel2 = true;
}
if (questionState1 === true) {
fill(255, 0, 0);
background(0);
textSize(100);
text("what will you choose?", windowWidth / 2, windowHeight / 2);
}
if (questionState2 === true) {
fill(255, 0, 0);
background(0);
textSize(32);
text("what does this say about", windowWidth / 2, windowHeight / 4);
textSize(500);
text("YOU?", windowWidth / 2, windowHeight / 1.25);
}
if(viewedLabel1===true && viewedLabel2===true && showMacLabel === false && showBamLabel === false){
fill(255, 0, 0);
textFont(myFont);
textSize(32);
text("click anywhere to continue", windowWidth / 2, windowHeight/1.2);
}
}
function keyPressed() {
if (key === 'b' && (showBamLabel || showMacLabel)) {
background(fridgeshelf);
image(macncheese, 400, 200, 300, 300);
image(bam, 700, 5, 275, 275);
showMacLabel = false;
showBamLabel = false;
}
}
function mousePressed() {
if (bgShow === false) {
bgShow = true;
soundtrack.play();
}
if (actionFinished1 === true) {
fridgeOpen = true;
}
if (actionFinished2 === true) {
shelfShow = true;
}
if (actionFinished3 === true) {
if (mouseX > 400 && mouseX < 700 && mouseY > 200 && mouseY < 500) {
showMacLabel = true;
}
if (mouseX > 700 && mouseX < 975 && mouseY > 5 && mouseY < 280) {
showBamLabel = true;
}
}
if (questionState1 === true) {
questionState1 = false;
questionState2 = true;
questionState3=false
}
if (viewedLabel1 === true && viewedLabel2 === true) {
questionState1 = true;
}
}