xxxxxxxxxx
352
let myFont;
let animation1, animation2;
let state = "openingscreen";
let checkFridgeOpen = false;
let shelfShow = false;
let showMacLabel = false;
let showBamLabel = false;
let actionFinished1 = false;
let actionFinished2 = false;
let actionFinished3 = false;
let questionState1 = false;
let videoplaying = false;
let startTime = 0;
let bamSequence1 = false;
let bamSequence2 = false;
let bamSequence3 = false;
let bamSequence4 = false;
let bamSequence5 = false;
let viewedLabel1 = false;
let viewedLabel2 = false;
let animation1Finished = false;
let animation2Finished = false;
let animation2Start = false;
function setup() {
createCanvas(windowWidth, windowHeight);
soundtrack.loop();
soundtrack.setVolume(0.25);
jumpscare.setVolume(1);
textAlign(CENTER);
fill(255, 0, 0);
textFont(myFont);
animation1 = createVideo("microwaveanimation.mp4");
animation1.size(windowWidth, windowHeight);
animation1.volume(1);
animation1.hide();
animation2 = createVideo("macanimation.mp4");
animation2.size(windowWidth, windowHeight);
animation2.volume(1);
animation2.hide();
}
function preload() {
myFont = loadFont("PixelifySans-VariableFont_wght.ttf");
fridgeclosed = loadImage("fridgeclosed.png");
fridgeopen = loadImage("fridgeopen.png");
fridgeshelf = loadImage("fridgeshelf.png");
macncheese = loadImage("macncheese.png");
bam = loadImage("bamcan.png");
maclabel = loadImage("maclabel.png");
bamlabel = loadImage("bamlabel.png");
bamclosed = loadImage("bamclosed.png");
bamopened = loadImage("bamopened.png");
bamplate = loadImage("bamplate.png");
macimage = loadImage("macimage.png");
soundtrack = loadSound("soundtrack.mp3");
jumpscare = loadSound("jumpscare.mp3");
}
function draw() {
if (state === "openingscreen") {
background(0);
textSize(100);
text("i'm hungry", windowWidth / 2, windowHeight / 2);
textSize(32);
text("click anywhere to start", windowWidth / 2, windowHeight / 1.2);
} else if (state === "gamestarted") {
image(fridgeclosed, 0, 0, windowWidth, windowHeight);
}
if (checkFridgeOpen === false && state === "gamestarted") {
image(fridgeclosed, 0, 0, windowWidth, windowHeight);
actionFinished1 = true;
} else if (checkFridgeOpen === true) {
image(fridgeopen, 0, 0, windowWidth, windowHeight);
actionFinished2 = true;
}
if (shelfShow === true) {
image(fridgeshelf, 0, 0, windowWidth, windowHeight);
actionFinished3 = true;
image(
macncheese,
windowWidth / 2.5,
windowHeight / 1.41,
windowWidth / 4.5,
windowHeight / 5
);
image(
bam,
windowWidth / 5.1,
windowHeight / 2.14,
windowWidth / 3.2,
windowHeight / 5.1
);
}
if (shelfShow === true && showMacLabel === true && questionState1 === false) {
image(
maclabel,
windowWidth / 20,
windowHeight / 15,
windowWidth / 1.2,
windowHeight / 1.2
);
textSize(48);
text("press 'b' to go back", windowWidth / 2, windowHeight / 1.04);
viewedLabel1 = true;
}
if (shelfShow === true && showBamLabel === true && questionState1 === false) {
image(
bamlabel,
windowWidth / 20,
windowHeight / 15,
windowWidth / 1.2,
windowHeight / 1.2
);
textSize(48);
text("press 'b' to go back", windowWidth / 2, windowHeight / 1.04);
viewedLabel2 = true;
}
if (
viewedLabel1 === true &&
viewedLabel2 === true &&
showMacLabel === false &&
showBamLabel === false &&
state === "gamestarted"
) {
questionState1 = true;
textSize(125);
text("what will you choose?", windowWidth / 2, windowHeight / 4);
//BAM
if (
mouseX > windowWidth / 3.4 &&
mouseX < windowWidth / 2.3 &&
mouseY > windowHeight / 2.1 &&
mouseY < windowHeight / 1.5
) {
image(
bam,
windowWidth / 7.75,
windowHeight / 2.25,
windowWidth / 2.2,
windowHeight / 4
);
}
//MAC
if (
mouseX > windowWidth / 2.4 &&
mouseX < windowWidth / 1.7 &&
mouseY > windowHeight / 1.4 &&
mouseY < windowHeight / 1.11
) {
image(
macncheese,
windowWidth / 2.68,
windowHeight / 1.5,
windowWidth / 3.5,
windowHeight / 4.1
);
}
}
if (state === "CHOSEBAM") {
image(bamclosed, 0, 0, windowWidth, windowHeight);
//console.log("this code ran 1")
}
if (state === "bamEnd1") {
image(bamopened, 0, 0, windowWidth, windowHeight);
//console.log("this code ran 2")
}
if (state === "bamEnd2") {
image(bamplate, 0, 0, windowWidth, windowHeight);
//console.log("this code ran 3")
}
if (state === "bamEnd3") {
background(0);
textSize(85);
text("is this really what you want...?", windowWidth / 2, windowHeight / 2);
//console.log("this code ran 3")
}
if (state === "bamEnd4") {
background(0);
textSize(32);
text("what does this say about", windowWidth / 2, windowHeight / 4);
textSize(550);
text("YOU?", windowWidth / 2, windowHeight / 1.25);
//console.log("this code ran 4")
}
if (state === "CHOSEMAC") {
if (!videoplaying) {
animation1.play();
startTime = millis();
videoplaying = true;
}
let passedTime = millis() - startTime;
if (passedTime < 12990) {
image(animation1, 0, 0, windowWidth, windowHeight);
} else {
animation1.stop();
animation1Finished = true;
background(macimage);
}
}
if (state === "CHOSEMAC" && animation1Finished && !animation2Start) {
animation2Start = true;
startTime = millis();
videoplaying = false;
}
if (state === "CHOSEMAC" && animation2Start) {
if (!videoplaying) {
animation2.play();
videoplaying = true;
}
let passedTime = millis() - startTime;
if (passedTime < 3990) {
image(animation2, 0, 0, windowWidth, windowHeight);
} else {
animation2.stop();
animation2Finished = true;
}
}
if (animation2Finished === true) {
background(0);
textSize(85);
text("ahhh... that tastes good", windowWidth / 2, windowHeight / 2);
}
}
function keyPressed() {
if (key === "b" && (showBamLabel || showMacLabel)) {
showMacLabel = false;
showBamLabel = false;
}
}
function mousePressed() {
if (state === "openingscreen") {
state = "gamestarted";
soundtrack.play();
return;
}
if (checkFridgeOpen === false) {
if (
mouseX > windowWidth / 6 &&
mouseX < windowWidth / 1.5 &&
mouseY > windowHeight / 3 &&
mouseY < windowHeight / 1.1
) {
checkFridgeOpen = true;
}
}
if (actionFinished1 === true && actionFinished2 === true) {
if (
mouseX > windowWidth / 6 &&
mouseX < windowWidth / 1.5 &&
mouseY > windowHeight / 3 &&
mouseY < windowHeight / 1.1
) {
shelfShow = true;
}
}
if (shelfShow === true && questionState1 === false) {
if (
mouseX > windowWidth / 2.4 &&
mouseX < windowWidth / 1.7 &&
mouseY > windowHeight / 1.4 &&
mouseY < windowHeight / 1.11
) {
showMacLabel = true;
}
if (
mouseX > windowWidth / 3.4 &&
mouseX < windowWidth / 2.3 &&
mouseY > windowHeight / 2.1 &&
mouseY < windowHeight / 1.5
) {
showBamLabel = true;
}
}
if (
viewedLabel1 === true &&
viewedLabel2 === true &&
showMacLabel === false &&
showBamLabel === false &&
state === "gamestarted"
) {
if (
mouseX > windowWidth / 2.4 &&
mouseX < windowWidth / 1.7 &&
mouseY > windowHeight / 1.4 &&
mouseY < windowHeight / 1.11
) {
state = "CHOSEMAC";
showMacLabel = false;
showBamLabel = false;
}
if (
mouseX > windowWidth / 3.4 &&
mouseX < windowWidth / 2.3 &&
mouseY > windowHeight / 2.1 &&
mouseY < windowHeight / 1.5
) {
state = "CHOSEBAM";
showMacLabel = false;
showBamLabel = false;
return;
}
}
if (state === "CHOSEBAM") {
state = "bamEnd1";
return;
}
if (state === "bamEnd1") {
state = "bamEnd2";
return;
}
if (state === "bamEnd2") {
state = "bamEnd3";
return;
}
if (state === "bamEnd3") {
state = "bamEnd4";
jumpscare.play();
return;
}
}