I tried to put this text (Das war’s Danke für’s mitmachen) on flag 3 but it did not work, why?
int flag = 0;
// 3 parallel arrays
String[] text1 = {
"1. Aussage:",
"2. Aussage:",
"3. Aussage:",
"4. Aussage:",
"5. Aussage:",
"6. Aussage:",
};
String[] text2 = {
"Wir haben einen nicht gelisteten Helfer.",
" Wir sind das erste Mal dabei.",
"Unser Team besteht nur aus Leuten aus der 7. Klasse.",
" Unserer ITler ist der coolste.",
"Beim letzten Wettkampf kamen wir in die Top 5.",
"Unsere Schule stellt ein anderes Team.",
};
int[] correct = {
1,
2,
2,
1,
2,
1,
};
// index for all 3
int index = 0;
void setup() {
size( 1920,1080);
background(255);
}//func
void draw() {
background(255);
actOnFlag();
}//func
// -------------------------------------------------
void actOnFlag() {
if (flag == 0) {
// Question 1
pushStyle();
background(255);
fill(255, 0, 0);
rect (700, 300, 300, 300);
fill(0, 255, 0);
rect (300, 300, 300, 300);
fill(0, 0, 0);
text(text1[index], 600, 150);
text(text2[index], 350, 190);
textSize(32);
fill(0, 51, 0);
text("WAHR", 400, 450);
textSize(32);
fill( 128, 0, 0);
text("FALSCH", 800, 450);
pushStyle();
} else if (flag == 1 || flag == 2) {
//
resultScreen();
} else if (flag == 3) {
pushStyle();
fill(0);
rect(1316, 0, 50, 50);
textSize(23);
fill(255);
text("<-", 1326, 30);
textSize(32);
text("Das war's", 600, 150);
text("Danke für's mitmachen", 600, 200);
pushStyle();
flag=0;
index++;
} else {
background(255);
textSize(32);
fill(255, 0, 0);
text("Error in actOnFlag: "+flag, 600, 150);
}
}//func
void resultScreen() {
if ((flag == 1 && correct[index] == 1) || (flag == 2 && correct[index] == 2)) {
// Correct
pushStyle();
background(255);
fill(0, 255, 0);
textSize(42);
text("Richtig!", 600, 150);
fill(0);
rect(600, 300, 300, 300);
textSize(32);
fill(255);
text("Nächste", 700, 400);
text("Aussage->", 700, 450);
fill(0);
rect(1316, 0, 50, 50);
textSize(23);
fill(255);
text("<-", 1326, 30);
popStyle();
} else {
// Wrong
pushStyle();
background(255);
fill(255, 0, 0);
text("Falsch!", 600, 150);
fill(0);
rect(600, 300, 300, 300);
textSize(32);
fill(255);
text("Nächste", 700, 400);
text("Aussage->", 700, 450);
fill(0);
rect(1316, 0, 50, 50);
textSize(23);
fill(255);
text("<-", 1326, 30);
popStyle();
}
}//
// -------------------------------------------------
void mousePressed() {
println("MouseX: " + mouseX + " MouseY: " + mouseY + " Flag: " + flag);
//------------------------
if (flag == 0) {
// Question 1
if (mouseX>300 && mouseX < 600 && mouseY >300 && mouseY <600) {
flag = 1;
}
if (dist(mouseX, mouseY, 849, 450)<125) {
flag = 2;
}
}
//------------------------
// Two result screens with a "Next button"
else if (flag == 1) {
// Correct
if (mouseX>600 && mouseX < 900 && mouseY >300 && mouseY <600) {
flag = 3; // both proceed to Question 2
}
} else if (flag == 2) {
// Wrong
if (mouseX>600 && mouseX < 900 && mouseY >300 && mouseY <600) {
flag = 3; // both proceed to Question 2
}
}
//---------------------
if (flag ==2 || flag == 1 || flag ==3) {
if (mouseX>1316 && mouseX < 1366 && mouseY >0 && mouseY <50) {
flag = 0;
}//if
//--------------------
else {
// flag = 0;
}
//
}//func
}