Hello everyone,
Im coding a quiz but Im just a beginner.
So there is one thing I need help with:
What I want:
When the answer is correct it needs to go to the next picture.
How do I draw the next image when the answer is correct?
Can I do something like:
img=0
when answer is correct: img++
so then the next image is drawn for example img2
So I have to do this with picking a picture from an array but I don’t know how to set that up and pick it
Looking forward to a response!
PImage img1;
PImage img2;
PImage img3;
PImage img4;
String[] questions ={
"Rekenen voorbeeld",
"Vraag 1\n 5+5=?",
"Vraag 2\n 5+20=?",
"Vraag 3\n 20-5=?",
"Klaar, Goed gedaan!"};
String[] goodanswers={
"n.a.",
"a",
"b",
"c",
"n.a."};
int q=0, Correct=0, Pogingen = 0;
void setup() {
size (1280, 800);
img1 = loadImage("muur.jpg");
img2 = loadImage("kinderen.jpg");
img3 = loadImage("pink_wall.png");
img4 = loadImage("schoolkind.jpg");
println("mouse click: LEFT: next question, RIGHT: start again");
println("key: [a],[b], ... as indicated in the questions");
}
void draw() {
background(0, 0, 0);
image(img1, 0, 0);
fill(300,800,200); // text color
textSize(25);
//positie text
text(questions[q], 1000, 200);
//score
if ( Correct > 0 ) text("Vragen: "+Correct+" Pogingen: "+Pogingen, width - 300, 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("++ Correct!");
Correct++;
q++;
} else {
println("-- Helaas..., probeer opnieuw of skip met muis LEFT click");
Pogingen++;
}
}