Hello!
I want to make a true or false game, with these questions:
String Question1 = "Wir haben einen nicht gelisteten Helfer.";
String Question2 = " Wir sind das erste Mal dabei.";
String Question3 = "Unser Team besteht nur aus Leuten aus der 7. Klasse.";
String Question4 = " Unserer ITler ist der coolste.";
String Question5 = "Beim letzten Wettkampf kamen wir in die Top 5.";
String Question6 = "Unsere Schule stellt ein anderes Team.";
The Quiz has to appear, when you click the “QUIZ” Button, and there has to be this back button:
void draw_zurueck_button() { //_ state 1,2,3
fill(0, 0, 200);
if ( over(x5, y5, w5, h5) ) stroke(200, 0, 0);
else stroke(0);
rect(x5, y5, w5, h5);
fill(184, 18, 18);
textSize(55);
stroke(0);
text("zurück", x5 + 35, y5 + 68);
textSize(40);
fill(0, 0, 200);
}
,which brings you back to State 0 = the button-menu.
I just dont know, how to make something like that and it would be really nice, if you helped me!
Hole code:
int state = 0;
color green = color(72, 255, 0);
color red = color(255, 17, 0);
color lightblue = color(3, 182, 252);
/* boolean answer1 = true;
boolean answer2 = false;
boolean answer3 = false;
boolean answer4 = true;
boolean answer5 = false;
boolean answer6 = true;
String Question1 = "Wir haben einen nicht gelisteten Helfer.";
String Question2 = " Wir sind das erste Mal dabei.";
String Question3 = "Unser Team besteht nur aus Leuten aus der 7. Klasse.";
String Question4 = " Unserer ITler ist der coolste.";
String Question5 = "Beim letzten Wettkampf kamen wir in die Top 5.";
String Question6 = "Unsere Schule stellt ein anderes Team.";
int currentQuestion = 1;
*/
String QUIZ = "Q\nU\nI\nZ\n";
int x1=100, y1=100, w1=250, h1=250; //Button oben links
int x2=1570, y2=100, w2=250, h2=250; //Button oben rechts
int x3=100, y3=750, w3=250, h3=250; //Button unten links
int x4=1570, y4=750, w4=250, h4=250; //Button unten rechts
int x5=80, y5=910, w5=250, h5=100; // Button zurück
int x6=860, y6=0, w6=200, h6=1080; //Button Quiz
int x7=260, y7=290, w7=500, h7=500; //Quiz left Button
int x8=1160, y8=290, w8=500, h8=500; //Quiz right Button
void drawMainButtons() { //_______ stat 0 only
if ( over(x1, y1, w1, h1) ) stroke(200, 0, 0);
else stroke(0);
rect(x1, y1, w1, h1);
if ( over(x2, y2, w2, h2) ) stroke(200, 0, 0);
else stroke(0);
rect(x2, y2, w2, h2);
if ( over(x3, y3, w3, h3) ) stroke(200, 0, 0);
else stroke(0);
rect(x3, y3, w3, h3);
if ( over(x4, y4, w4, h4) ) stroke(200, 0, 0);
else stroke(0);
rect(x4, y4, w4, h4);
if ( over(x6, y6, w6, h6) ) stroke(200, 0, 0);
else stroke(0);
rect(x6, y6, w6, h6);
draw_quiz_text();
}
void draw_zurueck_button() { //_ state 1,2,3
fill(0, 0, 200);
if ( over(x5, y5, w5, h5) ) stroke(200, 0, 0);
else stroke(0);
rect(x5, y5, w5, h5);
fill(184, 18, 18);
textSize(55);
stroke(0);
text("zurück", x5 + 35, y5 + 68);
textSize(40);
fill(0, 0, 200);
}
void drawQuiz() {
background(lightblue);
}
void draw_quiz_text() {
fill(184, 18, 18);
textSize(150);
stroke(0);
textLeading(250);
textAlign(CENTER);
text(QUIZ, x6 + 95, y6 + 220);
textAlign(LEFT);
textSize(40);
fill(0, 0, 200);
}
void setup() {
fullScreen();
//size(1920, 1200);
fill(0, 0, 200);
strokeWeight(10);
}
void draw() {
background(68, 235, 7);
if ( state == 0 ) drawMainButtons();
if ( state == 1 ) draw_back_button_and_some_text1();
if ( state == 2 ) draw_back_button_and_some_text2();
if ( state == 3 ) draw_back_button_and_some_text3();
if ( state == 4 ) draw_back_button_and_some_text4();
if ( state == 6 ) drawQuiz();
}
void mousePressed() {
if ( state == 0 ) {
if ( over(x1, y1, w1, h1) ) state = 1;
if ( over(x2, y2, w2, h2) ) state = 2;
if ( over(x3, y3, w3, h3) ) state = 3;
if ( over(x4, y4, w4, h4) ) state = 4;
if ( over(x6, y6, w6, h6) ) state = 6;
if ( over(x7, y7, w7, h7) ) state = 7;
//if ( over(x7, y7, w7, h7) ) currentQuestion ++;
if ( over(x8, y8, w8, h8) ) state = 8;
//if ( over(x8, y8, w8, h8) ) currentQuestion ++;
} else {
if ( over(x5, y5, w5, h5) ) state = 0;
}
}
void draw_back_button_and_some_text1() {
fill(0);
text("some text page1 ", 760, 50);
draw_zurueck_button();
}
void draw_back_button_and_some_text2() {
fill(0);
text("some text page2 ", 760, 50);
draw_zurueck_button();
}
void draw_back_button_and_some_text3() {
fill(0);
text("some text page3 ", 760, 50);
draw_zurueck_button();
}
void draw_back_button_and_some_text4() {
fill(0);
text("some text page4 ", 760, 50);
draw_zurueck_button();
}
boolean over(int x, int y, int w, int h) {
return ( mouseX > x & mouseX < x + w &&
mouseY > y & mouseY < y + h ) ;
}