My Pictures disapear when using other commands

Before giving the Problem + code let me tell you my Programm.
Im trying to create a dress up game for my schoolwork.
You click on a bar and the game starts.
I’ve created 3 lines of arrows (pfeil) for that: <–(left) and -->(right) using for loops.(but that’s not imporant)
My goal for now is that when I click on the right arrow in the first row the body color changes. I’ve created an array full of pictures for that named haut. I got help for that but when I coded that if mousePressed the body should change, the pictures(arrows) disappear. I suspect it has to do something with redraw() but I don’t know how to fix that. In the code I only marked things grey which things are important for the Problem so you won’t get confused.

!!The Problem is at the bottom of the code!!

THE CODE:

//THE ARROWS VARIABLES (NOT IMPORTANT)
PImage pfeilRechts1Reihe;
PImage pfeilLinks1Reihe;
PImage pfeilRechts2Reihe;
PImage pfeilLinks2Reihe;
PImage pfeilRechts3Reihe;
PImage pfeilLinks3Reihe;
PImage pfeilRechts4Reihe;
PImage pfeilLinks4Reihe;
int pU= 35; //Umfang Pfeil
int posYErsteReihe= 230;
int posYZweiteReihe= 340;
int posYDritteReihe= 450;
int posYVierteReihe= 550;
int posXRechts1=80;
int posXLinks1=45;
int posXRechts2=80;
int posXLinks2=45;
int pfeil;
int pfeil2;
int hautzaehler=0; //VARIABLE FOR THE SKIN(IMPORTANT)
PImage base;
PImage haut1;
PImage haut2;
PImage haut3;
PImage haut4;
PImage haut; //ARRAY FOR THE SKIN
void setup() { //JUST LOADING IMAGES(NOT IMPORTANT
size(800, 600);
menu= loadImage(“AuswahlMenu.png”);
pfeilLinks1Reihe= loadImage(“PfeilLinks.png”);// Pfeile<
pfeilRechts1Reihe= loadImage(“PfeilRechts.png”);
pfeilLinks2Reihe= loadImage(“PfeilLinks.png”);
pfeilRechts2Reihe= loadImage(“PfeilRechts.png”);
pfeilLinks3Reihe= loadImage(“PfeilLinks.png”);
pfeilRechts3Reihe= loadImage(“PfeilRechts.png”);
pfeilLinks4Reihe= loadImage(“PfeilLinks.png”);
pfeilRechts4Reihe= loadImage(“PfeilRechts.png”);// >Pfeile
startBildschirm= loadImage(“StartBildschirm.png”);
clickbarStartbildschirm= loadImage(“ClickbarStartbildschirm.png”);
clickToStartText= loadImage(“ClickToStartText.png”);
titel= loadImage(“Titel.png”);
haut= new PImage[5]; //THE ARRAY(IMPORTANT)
haut[0]= loadImage(“Base.png”);
haut[1]= loadImage(“Haut1.png”);
haut[2]= loadImage(“Haut2.png”);
haut[3]= loadImage(“Haut3.png”);
haut[4]= loadImage(“Haut4.png”);
}
void draw() { ///CODING THE STARTSCREEN(NOT IMPORTANT)
if(start==false){
imageMode(CENTER);
image(startBildschirm,width/2,height/2,width,height);
image(titel,405,350,700,700);
rect(250,350,300,100);
image(clickToStartText,405,310,650,600);
starten();
}
if (start==true){
//Hintergrund fehlt
imageMode(CORNER);
mage(haut[hautzaehler],280,00,600,600); //THE BODY(IMPORTANT)
image(menu,0,0,800,600);//Menü
pfeileErstellen1Und2Reihe();
pfeileErstellen3Reihe();
}
}
//PLACING THE ARROWS WHICH DISAPPEAR (SOMEWHAT IMPORTANT)
void pfeileErstellen1Und2Reihe(){ //function 1 and 2 row
for(int i= 0; pfeil<5; pfeil++){//Pfeil ++ damit es sich nur einmal wiederholt
imageMode(CENTER);
image(pfeilLinks1Reihe, posXLinks1, posYErsteReihe, pU, pU);
image(pfeilRechts1Reihe, posXRechts1, posYErsteReihe, pU, pU);
image(pfeilLinks2Reihe, posXLinks1, posYZweiteReihe, pU, pU);
image(pfeilRechts2Reihe, posXRechts1, posYZweiteReihe, pU, pU);
image(pfeilLinks3Reihe, posXLinks1, posYDritteReihe, pU, pU);
image(pfeilRechts3Reihe, posXRechts1, posYDritteReihe, pU, pU);
posXRechts1+=75;
posXLinks1+=75;
noLoop(); //So the loop won’t repeat itself and only the necessary arrows appear
}
}
void pfeileErstellen3Reihe(){ //function 3 row
for(int i= 0; pfeil2<3; pfeil2++){//Pfeil ++ damit es sich nur einmal wiederholt
imageMode(CENTER);
image(pfeilRechts4Reihe, posXRechts2, posYVierteReihe, pU, pU);
image(pfeilLinks4Reihe, posXLinks2 ,posYVierteReihe, pU, pU);
posXRechts2+=75;
posXLinks2+=75;
noLoop();
}
}
//HERE’S THE PROBLEM:
void mousePressed(){
if(dist (mouseX,mouseY, 45,230) <35){ //arrow position
hautzaehler= (hautzaehler +1) % haut.length;
redraw();
}
}

1 Like

Hi

Are you both in the same class :smiling_face::smiling_face:

Hi again

Sorry I did not read the names :smiley:

We? I just asked multiple questions. That question is also me :laughing: