i understand it might be too much,
but just take a look to see that there are some other possible
- program structures
- ways like array…
to do that:
( example)
String[] questions ={
"start text",
"qa\n[a] bla\n[b] blb\n[c] blc",
"qb\n[a]\n[b]\n[c]",
"qc\n[a]\n[b]\n[c]",
"end"};
String[] goodanswers={
"n.a.",
"a",
"c",
"b",
"n.a."};
int q=0, grade=0, gambler = 0;
void setup() {
size (500, 500);
println("mouse click: LEFT: next question, RIGHT: start again");
println("key: [a],[b], ... as indicated in the questions");
}
void draw() {
background(200, 200, 0);
fill(0,200,200); // text color
textSize(25);
text(questions[q], 10, 20);
fill(0,200,0); // text color
textSize(15);
if ( grade > 0 ) text("grade: "+grade+" fails: "+gambler, width - 200, height - 20);
}
void mousePressed() {
if ( mouseButton == LEFT ) q++;
if ( q > 4 ) exit();
if ( mouseButton == RIGHT ) q = 0;
}
void keyPressed() {
//println("key: "+key+" keyCode "+keyCode);
if ( goodanswers[q].equals(str(key)) ) {
println("++ ha, expert");
grade++;
q++;
} else {
println("-- bad guess, try again or skip with mouse LEFT click");
gambler++;
}
}