xxxxxxxxxx
951
// Layering class
let sceneManager;
// Scenes
let WScreen, Instructions, House, Room, Room2, Bathroom, Lounge, Kitchen, DiningRoom;
// Preloading the files
function preload() {
// Images
WScreen = loadImage('wscreen.png');
Instructions = loadImage('instructions.png');
Bathroom = loadImage('bathroom_bg.png');
House = loadImage('house_bg.png');
Kitchen = loadImage('kitchen_bg.png');
Room2 = loadImage('room2_bg.png');
Room = loadImage('room_bg.png');
Lounge = loadImage('lounge_bg.png');
DiningRoom = loadImage('diningroom_bg.png');
// Sounds
//for home screen
merhba = loadSound('merhba.m4a');
// for room 1
biro = loadSound('biro.m4a');
bola = loadSound('bola.m4a');
koursi= loadSound('koursi.m4a');
ktouba = loadSound('ktouba.m4a');
magana = loadSound('magana.m4a');
namousiya = loadSound ('namousiya.m4a');
tabla = loadSound ('tabla.m4a');
tablo = loadSound ('tablo.m4a');
koraardiya = loadSound('kora ardiya.m4a')
//for room 2
comoda = loadSound('comoda.m4a');
mraya = loadSound('mraya.m4a');
nebta = loadSound('nebta.m4a');
tswera = loadSound('tswera.m4a');
vase = loadSound('vase.m4a');
//for the bathroom
bainoir = loadSound('bainoir.m4a');
doo = loadSound('do.m4a');
fota = loadSound('fota.m4a');
khamia = loadSound('khamia.m4a');
lavabo = loadSound('lavabo.m4a');
sabon = loadSound('sabon.m4a');
shampoing = loadSound('shampoing.m4a');
toilette = loadSound('toilette.m4a');
zbel = loadSound('zbel.m4a');
papierhygienique = loadSound('papierhygienique.m4a');
//for the kitchen
ma3en = loadSound('ma3en.m4a');
kisan = loadSound('kisan.m4a');
khlata = loadSound('khlata.m4a');
makintlma3en = loadSound('makintlma3en.m4a');
m9raj = loadSound('m9raj.m4a');
fran = loadSound('fran.m4a');
placard = loadSound('placard.m4a');
tlaja = loadSound('tlaja.m4a');
tiroir = loadSound('tiroir.m4a');
//for the dining room
cherjem = loadSound('cherjem.m4a');
berrad = loadSound('berrad.m4a');
//for lounge
mecha = loadSound('mecha.m4a');
sedari = loadSound('sedari.m4a');
// Songs
song = loadSound('song.mp3');
song1 = loadSound('song1.mp3');
}
// Setup
function setup() {
createCanvas(945, 600);
rectMode(CENTER);
//class for managing layers
sceneManager = new SceneManager();
}
// Draw function
function draw() {
// Position of the mouse
print(mouseX + "," + mouseY);
sceneManager.display();
}
//SceneManager class starts here
class SceneManager {
constructor() {
this.onWScreen = true;
this.onInstructions = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
display() {
//welcome screen
if (this.onWScreen) {
image(WScreen, 0, 0);
this.onInstructions = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//instructions screen
else if (this.onInstructions){
image(Instructions, 0, 0);
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//House scene
else if (this.onHouse){
image (House, 0, 0);
this.onWScreen = false;
this.onInstructions = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//room scene
else if (this.onRoom){
image(Room,0,0);
this.onWScreen = false;
this.onHouse = false;
this.onInstructions = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//second room scene
else if (this.onRoom2){
image(Room2, 0, 0)
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onInstructions = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//bathroom scene
else if (this.onBathroom){
image(Bathroom, 0, 0);
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onInstructions = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//kitchen scene
else if (this.onKitchen){
image(Kitchen, 0, 0);
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onInstructions = false;
this.onBathroom = false;
this.onLounge = false;
this.onDiningRoom = false;
}
//dining room scene
else if (this.onDiningRoom){
image(DiningRoom, 0, 0);
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onLounge = false;
this.onInstructions = false;
}
//lounge scene
else if (this.onLounge){
image(Lounge, 0, 0);
this.onWScreen = false;
this.onHouse = false;
this.onRoom = false;
this.onRoom2 = false;
this.onKitchen = false;
this.onBathroom = false;
this.onDiningRoom = false;
this.onInstructions = false;
}
}
}
function mouseClicked(){
if(sceneManager.onWScreen){
if (
mouseX >= 250 &&
mouseX <= 600) {
if (
mouseY >= 336 &&
mouseY <= 600) {
print("gotoinstructions");
song1.play();
song1.setVolume(0.1);
song1.setLoop(true);
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = true;
sceneManager.onLounge = false;
return;
}
}
if(mouseX>=363 && mouseX<=553){
if(mouseY>=44 && mouseY<=74){
merhba.play();
}
}
}
if (sceneManager.onInstructions){
if (mouseX >= 0 &&
mouseX <= 220){
if (mouseY >=450 &&
mouseY <= 600){
print("gobacktohome");
clear ();
sceneManager.onWScreen = true;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
if (mouseX >= 740 &&
mouseX <= 920 ){
if (mouseY >= 470 &&
mouseY <= 600 ){
print("gotohouse");
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
}
if (sceneManager.onHouse){
//house's arrow
if (mouseX>= 20 &&
mouseX <= 130 ){
if (mouseY>= 20 &&
mouseY<= 95){
print("gobacktohome");
clear();
sceneManager.onWScreen = true;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//to click on room 1
if(mouseX>= 100 &&
mouseX<= 355){
if (mouseY>= 175 &&
mouseY<= 338){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = true;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//go to room 2
if (mouseX>=342 && mouseX<=587){
if (mouseY>=175 && mouseY<=355){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = true;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//go to the bathroom
if (mouseX>=592 && mouseX<=850)
{
if(mouseY>=175 && mouseY<=355){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = true;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//go to the kitchen
if(mouseX>=100 && mouseX<=410){
if(mouseY>=359 && mouseY <= 535){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = true;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//go to the dining room
if(mouseX>=420 && mouseX<=578){
if(mouseY>=359 && mouseY<=535){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = true;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//to go to the lounge
if(mouseX>=585 && mouseX<=849){
if(mouseY>=359 && mouseY<=535){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = false;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = true;
return;
}
}
}
if (sceneManager.onRoom) {
//to go back to house
if (mouseX>=24 && mouseX<=137) {
if (mouseY>=10 && mouseY<=56) {
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//books
if (mouseX>=41 && mouseX<=223){
if(mouseY>=114 && mouseY <=173){
ktouba.play();
}
}
//chair
if (mouseX>=174 && mouseX<=320){
if(mouseY>=329 && mouseY<=600){
koursi.play();
}
}
//desk
if (mouseX>=0 && mouseX<=157){
if(mouseY>=400 && mouseY<=600){
biro.play();
}
}
//clock
if (mouseX>=436 && mouseX<=565){
if(mouseY>=87 && mouseY<=215){
magana.play();
}
}
//table
if(mouseX>=478 && mouseX<=631){
if(mouseY>=512 && mouseY <= 600){
tabla.play();
}
}
//lamp
if(mouseX>=509 && mouseX<=605){
if (mouseY>=390 && mouseY<=507){
bola.play();
}
}
//bed
if(mouseX>=653 && mouseX<=945){
if(mouseY>=354 && mouseY<=600){
namousiya.play();
}
}
//painting
if(mouseX>=733 && mouseX<=902){
if(mouseY>=80 && mouseY<=249){
tablo.play();
}
}
//globe
if(mouseX>=222 && mouseX<=305){
if (mouseY>=70 && mouseY <= 173){
koraardiya.play();
}
}
}
if (sceneManager.onRoom2){
//to go back to house
if(mouseX>=0 && mouseX<=107){
if (mouseY>=0 && mouseY<=49){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//mirror
if (mouseX>=0 && mouseX<=206){
if(mouseY>=61 && mouseY <= 274){
mraya.play();
}
}
//picture
if (mouseX>=259 && mouseX<= 368){
if (mouseY>=128 && mouseY<=217){
tswera.play();
}
}
//painting
if (mouseX>=421 && mouseX<= 757){
if (mouseY >= 87 && mouseY<= 251)
{
tablo.play();
}
}
//bed
if(mouseX>=390 && mouseX<=795){
if(mouseY>=341 && mouseY <= 500){
namousiya.play();
}
}
//commode
if(mouseX>=0 && mouseX<=205){
if(mouseY>=390 && mouseY<=600){
comoda.play();
}
}
//lamp
if(mouseX>=273 && mouseX<=324){
if(mouseY>=347 && mouseY<=465){
bola.play();
}
}
//lamp 2
if(mouseX>=872 && mouseX<=921){
if(mouseY>=345 && mouseY<=467){
bola.play();
}
}
//table
if(mouseX>=223 && mouseX<=377){
if (mouseY >= 472 && mouseY <= 600){
tabla.play();
}
}
//table 2
if(mouseX>=810 && mouseX<=945){
if(mouseY>=493 && mouseY<=600){
tabla.play();
}
}
//plant
if (mouseX>=0 && mouseX<=86){
if(mouseY>=287 && mouseY<=383){
nebta.play();
}
}
//vase
if(mouseX>=815 && mouseX<=861){
if(mouseY>=336 && mouseY<=465){
vase.play();
}
}
//clock
if(mouseX>=833 && mouseX<=938){
if(mouseY>=124 && mouseY<=224){
magana.play();
}
}
}
if (sceneManager.onBathroom){
//to go back to house
if(mouseX>=0 && mouseX<=140){
if(mouseY>=0 && mouseY<=69){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//towel
if(mouseX>=40 && mouseX<=158){
if(mouseY>=96 && mouseY<=135){
fota.play();
}
}
//light1
if(mouseX>=204 && mouseX<=239){
if(mouseY>=154 && mouseY<=220){
doo.play();
}
}
//light2
if(mouseX>=416 && mouseX<=451){
if(mouseY>=153 && mouseY<=219){
doo.play();
}
}
//mirror
if(mouseX>=261 && mouseX<=396){
if(mouseY>=74 && mouseY<=275){
mraya.play();
}
}
//toilet
if(mouseX>=13 && mouseX<=107){
if(mouseY>=386 && mouseY <= 600){
toilette.play();
}
}
//lavabo
if(mouseX>=261 && mouseX<=396){
if (mouseY>=346 && mouseY <= 600){
lavabo.play();
}
}
//toilet paper
if(mouseX>=145 && mouseX<=176){
if(mouseY>=415 && mouseY<=439){
papierhygienique.play();
}
}
//soap
if(mouseX>=265 && mouseX<=292){
if(mouseY>=329 && mouseY<=341){
sabon.play();
}
}
//trash
if(mouseX>=133 && mouseX<=189){
if(mouseY>=508 && mouseY<=600){
zbel.play();
}
}
//rideau
if(mouseX>=707 && mouseX<=945){
if(mouseY>=109 && mouseY<=437){
khamia.play();
}
}
//shampoing
if(mouseX>=116 && mouseX<=171){
if(mouseY>=125 && mouseY<=222){
shampoing.play();
}
}
//bainoir
if(mouseX>=508 && mouseX<=916){
if(mouseY>=441 && mouseY<=555){
bainoir.play();
}
}
//towel2
if(mouseX>=29 && mouseX<=106){
if(mouseY>=189 && mouseY<=220){
fota.play();
}
}
//towel3
if(mouseX>=456 && mouseX<=519){
if(mouseY>=227 && mouseY<=373){
fota.play();
}
}
}
//to go to the kitchen
if(sceneManager.onKitchen){
//to go back to house
if(mouseX>=0 && mouseX<=137){
if(mouseY>=0 && mouseY<=67){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//fridge
if(mouseX>=0 && mouseX<=155){
if(mouseY>=133 && mouseY<=576){
tlaja.play();
}
}
//placard1
if(mouseX>=159 && mouseX<=358){
if(mouseY>=42 && mouseY<=238){
placard.play();
}
}
//placard2
if(mouseX>=528 && mouseX<=840){
if(mouseY>=40 && mouseY<=236){
placard.play();
}
}
//placard3
if(mouseX>=161 && mouseX<=357){
if(mouseY>=367 && mouseY<=563){
placard.play();
}
}
//dishwasher
if(mouseX>=682 && mouseX<=839){
if(mouseY>=367 && mouseY<=572){
makintlma3en.play();
}
}
//m9raj
if(mouseX>=461 && mouseX<=502){
if(mouseY>=304 && mouseY<=351){
m9raj.play();
}
}
//khlata
if(mouseX>=188 && mouseX<=251){
if(mouseY>=290 && mouseY<=360){
khlata.play();
}
}
//kisan
if(mouseX>=853 && mouseX<=945){
if(mouseY>=236 && mouseY<=262){
kisan.play();
}
}
//four
if(mouseX>=363 && mouseX<=526){
if(mouseY>=367 && mouseY<=572){
fran.play();
}
}
//placard4
if(mouseX>=840 && mouseX<=945){
if(mouseY>=367 && mouseY<=572){
placard.play();
}
}
//tiroir
if(mouseX>=531 && mouseX<=681){
if(mouseY>=367 && mouseY<=572){
tiroir.play();
}
}
}
if(sceneManager.onDiningRoom){
//to go back to house
if(mouseX>=0 && mouseX<=137){
if(mouseY>=532 && mouseY<=574){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//painting1
if(mouseX>=37 && mouseX<=198){
if(mouseY>=5 && mouseY<=215){
tablo.play();
}
}
//painting2
if(mouseX>=753 && mouseX<=910){
if(mouseY>=5 && mouseY<=215){
tablo.play();
}
}
//rideau
if(mouseX>=240 && mouseX<=711){
if(mouseY>=0 && mouseY<=185){
khamia.play();
}
}
//window
if(mouseX>=247 && mouseX<=702){
if(mouseY>=186 && mouseY<=376){
cherjem.play();
}
}
//table
if(mouseX>=163 && mouseX<=790){
if(mouseY>=435 && mouseY<=600){
tabla.play();
}
}
//chair1
if(mouseX>=50 && mouseX<=90){
if(mouseY>=350 && mouseY<=600){
koursi.play();
}
}
//chair2
if(mouseX>=852 && mouseY<=907){
if(mouseY>=350 && mouseY<=600){
koursi.play();
}
}
//teapot
if(mouseX>=404 && mouseX<=464){
if(mouseY>=382 && mouseY<=431){
berrad.play();
}
}
//glass1
if(mouseX>=213 && mouseX<=367){
if(mouseY>=406 && mouseY<=430){
kisan.play();
}
}
//glass2
if(mouseX>=579 && mouseX<=716){
if(mouseY>=406 && mouseY<=430){
kisan.play();
}
}
}
if(sceneManager.onLounge){
//to go back to house
if(mouseX>=0 && mouseX<=137){
if(mouseY>=0 && mouseY<=64){
clear();
sceneManager.onWScreen = false;
sceneManager.onHouse = true;
sceneManager.onRoom = false;
sceneManager.onRoom2 = false;
sceneManager.onKitchen = false;
sceneManager.onBathroom = false;
sceneManager.onDiningRoom = false;
sceneManager.onInstructions = false;
sceneManager.onLounge = false;
return;
}
}
//painting1
if(mouseX>=78 && mouseX<=213){
if(mouseY>=113 && mouseY<=245){
tablo.play();
}
}
//painting 2
if(mouseX>=732 && mouseX<=867){
if(mouseY>=113 && mouseY<=246){
tablo.play();
}
}
//rideau
if(mouseX>=281 && mouseX<=659){
if(mouseY>=14 && mouseY<=223){
khamia.play();
}
}
//window
if(mouseX>=425 && mouseX<=547){
if(mouseY>=232 && mouseY<=354){
cherjem.play();
}
}
//cat
if(mouseX>=584 && mouseX<=667){
if(mouseY>=418 && mouseY<=463){
mecha.play();
}
}
//table1
if(mouseX>=61 && mouseX<=169){
if(mouseY>=442 && mouseY<=546){
tabla.play();
}
}
//table2
if(mouseX>=777 && mouseX<=882){
if(mouseY>=445 && mouseY<=552){
tabla.play();
}
}
//sofa
if(mouseX>=408 && mouseX<=564){
if(mouseY>=363 && mouseY<=558){
sedari.play();
}
}
//teapot
if(mouseX>=310 && mouseX<=344){
if(mouseY>=457 && mouseY <=485){
berrad.play();
}
}
//plant1
if(mouseX>=80 && mouseX<=142){
if(mouseY>=343 && mouseY<=434){
nebta.play();
}
}
//plant2
if(mouseX>=327 && mouseX<=369){
if(mouseY>=275 && mouseY<=355){
nebta.play();
}
}
//plant3
if(mouseX>=383 && mouseX<=420){
if(mouseY>=286 && mouseY<=355){
nebta.play();
}
}
//plant4
if(mouseX>=565 && mouseX<=609){
if(mouseY>=234 && mouseY<=355){
nebta.play();
}
}
//books
if(mouseX>=776 && mouseX<=834){
if(mouseY>=413 & mouseY<=436){
ktouba.play();
}
}
}
}