xxxxxxxxxx
/*Our final project is a choose your own adventure experience through a haunted house theme. There are animations, mini-games, sounds, and other interactive qualities
within the routes you can take in the house.
*/
// Evaine: background IP is Roco Kingdom. Press "space" to start. Press "e" to go to my first scene. Find the 5 differences and press "f" to go to my second scene. Click the 5 objects and double click the middle one to go to win scene.
var titlefont;
var startimage;
var batimage;
var witchimage;
var candiesimage;
var ratimage;
let startsound;
var blink = 0;
let frames = 3;
var death = false;
var escape = false;
function preload(){
titlefont = loadFont('Gypsy Curse.ttf');
batimage = loadImage('batsprite.png');
witchimage = loadImage('witch3k.png');
candiesimage = loadImage('candies.png');
ratimage = loadImage('rat.png');
startimage = loadImage('startscene.jpg');
scene2background = loadImage('scene2pic.png');
scene3kbackground = loadImage('scene3kpic.jpg');
startsound = loadSound('scene1sound.mp3');
wcackle = loadSound('witchlaugh.mp3');
wscream = loadSound('scream.mp3');
E_background1 = loadImage('E_Hall.jpg'); // Evaine: background of SCENE 3E
E_background2 = loadImage('E_Hall_Again.jpg'); // Evaine: background of SCENE 4E
E_sound1 = loadSound('E_Sound1.mp3'); // Evaine: sound of SCENE 3E
E_sound2 = loadSound('E_Sound2.mp3'); // Evaine: sound of SCENE 4E
loadImage('E_Candle1.png'); // Evaine: image of left candle in SCENE 3E and its src below
E_srccandle1 = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Candle1.png';
loadImage('E_Candle2.png'); // Evaine: image of right candle in SCENE 3E and its src below
E_srccandle2 = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Candle2.png';
loadImage('E_Broom.png'); // Evaine: image of broom in SCENE 3E and its src below
E_srcbroom = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Broom.png';
loadImage('E_Carpet.png'); // Evaine: image of carpet in SCENE 3E and its src below
E_srccarpet = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Carpet.png';
loadImage('E_Sword.png'); // Evaine: image of sword in SCENE 3E and its src below
E_srcsword = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Sword.png';
loadImage('E_Flame.png'); // Evaine: image of flame in SCENE 3E and its src below
E_srcflame = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Flame.png';
loadImage('E_Flask.png'); // Evaine: image of flask in SCENE 4E and its src below
E_srcflask = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Flask.png';
loadImage('E_Picture.png'); // Evaine: image of picture in SCENE 4E and its src below
E_srcpicture = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Picture.png';
loadImage('E_Coffin.png'); // Evaine: image of coffin in SCENE 4E and its src below
E_srccoffin = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Coffin.png';
loadImage('E_Cage.png'); // Evaine: image of cage in SCENE 4E and its src below
E_srccage = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Cage.png';
loadImage('E_Pen.png'); // Evaine: image of pen in SCENE 4E and its src below
E_srcpen = 'https://deckard.openprocessing.org/user285108/visual1395888/ha535128fd5bbe92fbca45d81b025b2f0/E_Pen.png';
}
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(frames);
//scene3k buttons
candyB = createButton('CANDY');
candyB.size(170, 60);
candyB.style('background-color', 'pink');
candyB.style('font-size', '40px');
candyB.position(590, 590);
candyB.hide();
candyB.mouseClicked(playCackle);
ratsB = createButton('RATS');
ratsB.size(170, 60);
ratsB.style('background-color', 'gray');
ratsB.style('font-size', '40px');
ratsB.position(1400, 620);
ratsB.hide();
ratsB.mouseClicked(playScream);
E_candle1 = createImg(E_srccandle1, ''); // Evaine: button of left candle in SCENE 3E
E_candle1.position(80, 528); // Evaine: position of left candle in SCENE 3E
E_candle1.hide();
E_candle2 = createImg(E_srccandle2, ''); // Evaine: button of left candle in SCENE 3E
E_candle2.position(804, 528); // Evaine: position of left candle in SCENE 3E
E_candle2.hide();
E_broom = createImg(E_srcbroom, ''); // Evaine: button of broom in SCENE 3E
E_broom.position(1188, 312); // Evaine: position of broom in SCENE 3E
E_broom.hide();
E_carpet = createImg(E_srccarpet, ''); // Evaine: button of carpet in SCENE 3E
E_carpet.position(1018, 448); // Evaine: position of carpet in SCENE 3E
E_carpet.hide();
E_sword = createImg(E_srcsword, ''); // Evaine: button of sword in SCENE 3E
E_sword.position(1324, 296); // Evaine: position of sword in SCENE 3E
E_sword.hide();
E_flame = createImg(E_srcflame, ''); // Evaine: button of flame in SCENE 3E
E_flame.position(788, 380); // Evaine: position of flame in SCENE 3E
E_flame.hide();
E_flask = createImg(E_srcflask, ''); // Evaine: button of flask in SCENE 4E
E_flask.position(64, 580); // Evaine: position of flask in SCENE 4E
E_flask.hide();
E_picture = createImg(E_srcpicture, ''); // Evaine: button of picture in SCENE 4E
E_picture.position(318, 152); // Evaine: position of picture in SCENE 4E
E_picture.hide();
E_coffin = createImg(E_srccoffin, ''); // Evaine: button of coffin in SCENE 4E
E_coffin.position(600, 400); // Evaine: position of coffin in SCENE 4E
E_coffin.hide();
E_cage = createImg(E_srccage, ''); // Evaine: button of cage in SCENE 4E
E_cage.position(1014, 178); // Evaine: position of cage in SCENE 4E
E_cage.hide();
E_pen = createImg(E_srcpen, ''); // Evaine: button of pen in SCENE 4E
E_pen.position(1248, 386); // Evaine: position of pen in SCENE 4E
E_pen.hide();
}
function keyPressed() {
if(key == ' '){
scene2();
}
if(key == 'k'){
scene3k();
}
if(key === 'e') { // Evaine: click "e" to go to SCENE 3E
E_scene3(); // Evaine: function in SCENE 3E
}
if (key === 'f') { // Evaine: click "f" to go to SCENE 4E (Question)
E_scene4(); // Evaine: function in SCENE 4E
}
}
function scene1(){ //Kai
background(startimage);
//text
textAlign(CENTER); textSize(180); textFont(titlefont); fill(20); stroke(180); strokeWeight(10);
text('Will You Survive?', 590, 410);
textSize(100);
text('Evaine, Justine, Kai, Neha', 590, 540);
//add in music
//startsound.play(); //this seems to glitch out for some reason, does either or bat animation
//bat animation
push(); //bat1
translate(width/2, height/2);
translate(p5.Vector.fromAngle(millis()/1000, 200));
image(batimage, 180, -70, 300, 150);
pop();
push(); //bat2
translate(width/2, height/2);
translate(p5.Vector.fromAngle(millis()/1000, 80));
image(batimage, -400, 200, 260, 130);
pop();
push(); //bat3
translate(width/2, height/2);
translate(p5.Vector.fromAngle(millis()/1000, 40));
image(batimage, -720, -400, 300, 150);
pop();
//text
frameRate(frames); strokeWeight(1);
blink +=1;
if(blink%3 == 0){
fill(160, random(0,40), random(0, 40));
}
else{
noFill();
}
textSize(100);
text('[Press Space to Begin]', 590, 760);
loop();
}
function scene2(){ //Kai
background(scene2background);
//add in music
//add in text animations
blink +=1; frameRate(frames);
fill(0); textSize(160); textFont(titlefont); strokeWeight(5);
text('You open the front door and...', windowWidth/2, 300);
//Option 1
fill(160); textSize(90); strokeWeight(1);
text('walk straight ahead.', windowWidth/2, 500);
textSize(65);
if(blink%3 == 0){
fill(160, random(0,40), random(0, 40));
}
else{
noFill();
}
text('[Press e]', windowWidth/2, 580);
//Option 2
fill(160); textSize(90);
text('go down the left hallway.', windowWidth/5 - 80, 590);
textSize(65);
if(blink%3 == 0){
fill(160, random(0,40), random(0, 40));
}
else{
noFill();
}
text('[Press j]', windowWidth/5 - 80, 670);
//Option 3
fill(20); textSize(90);
text('go down the right hallway.', 4*windowWidth/5 + 80, 590);
textSize(65);
if(blink%3 == 0){
fill(160, random(0,40), random(0, 40));
}
else{
noFill();
}
text('[Press k]', 4*windowWidth/5 + 80, 670);
//Option 4
fill(20); textSize(90);
text('stay where you are.', windowWidth/2, 740);
textSize(65);
if(blink%3 == 0){
fill(160, random(0,40), random(0, 40));
}
else{
noFill();
}
text('[Press n]', windowWidth/2, 820);
loop();
}
function scene3k() {
//add in music & SE
background(scene3kbackground);
textSize(130); fill(20); stroke(180); strokeWeight(5);
text('You\'ve encountered a witch!', windowWidth/2, 150);
text('Give her either candy or rats.', windowWidth/2, 290);
image(witchimage, windowWidth/2, 400, 400, 400);
image(candiesimage, 570, 600, 250, 250);
image(ratimage, 1470, 480, 100, 100);
image(ratimage, 1420, 510, 100, 100);
image(ratimage, 1550, 550, 100, 100);
candyB.show();
ratsB.show();
if(death == true){ witchdeath();}
if(escape == true){ witchescape();}
noLoop();
}
function playCackle(){
wcackle.play();
death = true;
}
function playScream(){
wscream.play();
escape = true;
}
function witchdeath(){
if (death == true){
background(0); candyB.hide(); ratsB.hide(); textAlign(CENTER);
textSize(150); textFont(titlefont); fill(0, 150, 0); stroke(160);
text('She HATES candy!', windowWidth/2, 150);
text('Outraged, she casts a spell on you!', windowWidth/2, 300);
textSize(300); fill(150, 0, 0);
text('You Are DEAD!', windowWidth/2, 650);
}
}
function witchescape(){
if (escape == true){
background(0); candyB.hide(); ratsB.hide(); textAlign(CENTER);
textSize(130); textFont(titlefont); fill(0, 150, 0); stroke(160);
text('"THEY ARE SO CUTE! I LOVE THEM!"', windowWidth/2, 150);
text('She gratefully shows you out of the haunted house!', windowWidth/2, 300);
textSize(300); fill(150, 0, 0);
text('You Have ESCAPED!', windowWidth/2, 650);
}
}
function draw(){
scene1();
if(keyPressed(' ')){
scene2();
//after scene 2 only:
if(keyPressed('e')){
}
if(keyPressed('j')){
}
if(keyPressed('k')){
/*scene3k();
if(candyB.mouseClicked) witchdeath();
if(ratsB.mouseClicked) witchescape();*/
}
if(keyPressed('n')){
}
}
}
function E_scene3() {
startsound.stop();
E_sound1.play();
background(0);
image(E_background1, 0, -84, 1440, 900); // Evaine: background of SCENE 3E
textAlign(CENTER);
textSize(80);
fill(180);
text('Find the Differences (Click on the Right Side)', 720, 100);
text('Discover 5 or Die (Press f Only After you Discover All!)', 720, 675);
E_candle1.show();
E_candle2.show();
E_candle2.mouseClicked(E_draw1); // Evaine: function of candle in SCENE 3E
E_broom.show();
E_broom.mouseClicked(E_draw2); // Evaine: function of broom in SCENE 3E
E_carpet.show();
E_carpet.mouseClicked(E_draw3); // Evaine: function of carpet in SCENE 3E
E_sword.show();
E_sword.mouseClicked(E_draw4); // Evaine: function of sword in SCENE 3E
E_flame.show();
E_flame.mouseClicked(E_draw5); // Evaine: function of flame in SCENE 3E
if(E_candle2.mouseClicked & E_broom.mouseClicked) E_scene4();
}
function E_draw1() {
stroke('red');
noFill();
circle(106, 560, 75); // Evaine: circle left candle in SCENE 3E
circle(834, 560, 75); // Evaine: circle right candle in SCENE 3E
}
function E_draw2() {
stroke('red');
noFill();
circle(510, 376, 132); // Evaine: circle left broom in SCENE 3E
circle(1228, 376, 132); // Evaine: circle rigt broom in SCENE 3E
}
function E_draw3() {
stroke('red');
noFill();
circle(372, 486, 140); // Evaine: circle left carpet in SCENE 3E
circle(1090, 486, 140); // Evaine: circle right carpet in SCENE 3E
}
function E_draw4() {
stroke('red');
noFill();
circle(640, 370, 140); // Evaine: circle left sword in SCENE 3E
circle(1360, 370, 140); // Evaine: circle right sword in SCENE 3E
}
function E_draw5() {
stroke('red');
noFill();
circle(112, 426, 104); // Evaine: circle left flame in SCENE 3E
circle(832, 426, 104); // Evaine: circle right flame in SCENE 3E
}
function E_scene4() {
E_candle1.hide();
E_candle2.hide();
E_broom.hide();
E_carpet.hide();
E_sword.hide();
E_flame.hide();
E_sound1.stop();
E_sound2.play();
background(0);
image(E_background2, 0, 0, 1440, 800); // Evaine: background of SCENE 4E
textAlign(CENTER);
textSize(80);
noStroke();
fill(180);
text('Click the 5 Objects to Read the Messages', 720, 680);
E_flask.show();
E_flask.mouseClicked(E_draw6); // Evaine: function of flask in SCENE 4E
E_picture.show();
E_picture.mouseClicked(E_draw7); // Evaine: function of picture in SCENE 4E
E_coffin.show();
E_coffin.mouseClicked(E_draw8); // Evaine: function of coffin in SCENE 4E
E_coffin.doubleClicked(scene5); // Evaine: go to SCENE 5 when double clicked
E_cage.show();
E_cage.mouseClicked(E_draw9); // Evaine: function of cage in SCENE 4E
E_pen.show();
E_pen.mouseClicked(E_draw10); // Evaine: function of pen in SCENE 4E
}
function E_draw6() {
textAlign(LEFT);
textSize(40);
noStroke();
fill(160, 0, 0);
text('Do you really want to be immortal?', 48, 560); // Evaine: message of flask
}
function E_draw7() {
textAlign(CENTER);
textSize(40);
noStroke();
fill(160, 0, 0);
text('The portrait of the next Count will be here.', 348, 136); // Evaine: message of picture
}
function E_draw8() {
textAlign(CENTER);
textSize(40);
noStroke();
fill(160, 0, 0);
text('Promise me! Leave here right now and never come back again!', 708, 348); // Evaine: message of coffin
text('Double click the coffin.', 708, 388); // Evaine: message of win
}
function E_draw9() {
textAlign(CENTER);
textSize(40);
noStroke();
fill(160, 0, 0);
text('A bird in the cage... A bat in the cage... A soul in the cage...', 1048, 168); // Evaine: message of cage
}
function E_draw10() {
textAlign(RIGHT);
textSize(40);
noStroke();
fill(160, 0, 0);
text('He used the pen. He will use the pen? He is using the pen!', 1400, 468); // Evaine: message of pen
}
function scene5() { // win
E_candle1.hide();
E_candle2.hide();
E_broom.hide();
E_carpet.hide();
E_sword.hide();
E_flame.hide();
E_flask.hide();
E_picture.hide();
E_coffin.hide();
E_cage.hide();
E_pen.hide();
E_sound1.stop();
E_sound2.stop();
background(0);
textAlign(CENTER); textSize(100); textFont(titlefont);
noStroke();
fill(180);
text('You got out of the haunted house and survived!', windowWidth/2, windowHeight/2);
}