This is my 3 digit code:
class secretcode{
PImage [] img = new PImage [10] ;
PImage code;
int a = 1;
int currentImg=1;
int secondImg=1;
int thirdImg=1;
Boolean cijfer1=false;
Boolean cijfer2=false;
Boolean cijfer3=false;
PImage binnenkant;
String s = "Ga naar het eerste cijfer met rechter pijltje, naar het tweede cijfer met pijltje omhoog en naar het derde cijfer met linker pijltje";
void setup() {
size(1280, 720);
binnenkant = loadImage("binnenkant.jpg");
binnenkant.resize(width,height);
code = loadImage("Code.png");
code.resize(width, height);
for (int i=1; i<=9; i = i+1) {
img[i] = loadImage(i+".png");
}
textSize(20);
}
void draw() {
}
// ------------------------------------------------------------
void keyPressed() {
//first digit
if (keyCode == LEFT){
a=1;
}
if (key >= '1' && key <= '9' && a==1) {
currentImg=int(key-48);
}
if (keyCode == UP ){
a = 2;
}
//second digit
if (key >= '1' && key <= '9' && a==2) {
secondImg=int(key-48);
}
if (keyCode == RIGHT && a == 2){
a = 3;
}
//third digit
if (key >= '1' && key <= '9' && a==3) {
thirdImg=int(key-48);
}
}
}
and this is the code of the room:
secretcode C = new secretcode();
PImage Basementstickers;
PImage Tafel_omlaag;
PImage Tafel_omhoog;
PImage pizzaopen;
PImage pizzadicht;
PImage Pijl;
PImage Key1;
PImage SDG2;
PImage SDG2_blank;
PImage SDG3;
PImage SDG3_blank;
PImage SDG7;
PImage SDG7_blank;
PImage Stickers;
PImage kast;
PImage kader;
Boolean kelder=true;
Boolean Tafel=false;
PImage Homer;
Boolean pizza=false;
Boolean closet=false;
int[] vlijnen = { 250, 385, 400, 470, 490, 554, 614, 700, 800 };
int[] hlijnen = {36, 110, 165, 260, 300, 310, 350, 380, 400, 435, 480, 550};
void setup() {
size(1280, 720);
display();
Basementstickers= loadImage("Basementstickers.png");
pizzadicht = loadImage("pizzadicht.png");
pizzaopen = loadImage("pizzaopen.png");
Pijl= loadImage("Pijl.jpg");
Key1= loadImage("Key1.png");
SDG2= loadImage("SDG2.jpeg");
SDG3= loadImage("SDG3.jpg");
SDG7= loadImage ("SDG7.png");
Stickers= loadImage("Stickers.png");
Tafel_omlaag= loadImage("Tafel_omlaag.png");
Tafel_omhoog= loadImage("Tafel_omhoog.png");
kast = loadImage("kast1.png");
kader = loadImage("unnamed.png");
background(Basementstickers);
Homer= loadImage("Homer.png");
noStroke();
}
void draw() {
if (kelder == true) {
C.display();
C.play();
image(kader, 1080, 10, 200, 200);
image(kader, 1080, 200, 200, 200);
image(kader, 1080, 390, 200, 200);
}
for (int i = 0; i < vlijnen.length; i++) {
line(vlijnen[i], 0, vlijnen[i], 720);
}
for (int i = 0; i < hlijnen.length; i++) {
line(0, hlijnen[i], 1280, hlijnen[i]);
}
}
void display() {
}
void mouseClicked() {
//Sticker op tafel
if (mouseX>750 && mouseX<850 && mouseY>200 && mouseY<300 && kelder==false && Tafel==true) {
background(Tafel_omhoog);
image(Pijl, 0, 620, 100, 100);
}
//blad omhoog doen op tafel
if (mouseX>700 && mouseX<800 && mouseY>300 && mouseY<400 && kelder==true && Tafel==false) {
background(Tafel_omlaag);
image(Pijl, 0, 620, 100, 100);
kelder=false;
Tafel=true;
}
//stickers in kader
if (mouseX>385 &&mouseX<470 && mouseY>36 && mouseY<165 && kelder==true ) {
background(Stickers);
image(Pijl, 0, 620, 100, 100);
kelder=false;
}
//terug naar kelder
if (mouseX<100 &&mouseX>0 && mouseY<720 && mouseY>620 && kelder==false ) {
background(Basementstickers);
kelder=true;
Tafel=false;
}
//pizzadoos laten zien
if (mouseX<490 && mouseX>400 && mouseY<480 && mouseY>435 && kelder==true &&pizza==false) {
background(pizzadicht);
image(Pijl, 0, 620, 100, 100);
kelder = false;
pizza = true;
}
if (mouseX<700 && mouseX>470 && mouseY>350 && mouseY<550 && kelder==false && pizza==true) {
background(pizzaopen);
image(Pijl, 0, 620, 100, 100);
kelder= false;
pizza = false;
}
//kast
if (mouseX<400 && mouseX>250 && mouseY>110 && mouseY<380 && kelder==true && closet==false) {
background(kast);
image(Pijl, 0, 620, 100, 100);
kelder = false;
closet = true;
}
if (mouseX<310 && mouseX>260 && mouseY>552 && mouseY<650 && kelder==false && closet==true) {
}
}