True and false keycodes for game (Quiz / true or false game)

Remove the incrementing in the keyPressed t and f functions. Generally, what are they used for? If you press enter, if the answer is right you get correctAnswer++, but if you press t and give in the wrong answer, you get correctAnswer++ and wrongAnswer++… you shouldn‘t set correctAnswer++, only because the t key is pressed.

Im assuming you intended to go with t for true and f for false as an answer and somewhere decided to have people write the answer out as a text and then decide wether it‘s the correct answer, but you can‘t use both at the same time (that just doesn’t make much sense, though you could technically do it…).

Im not sure how clear i‘m being right now, but in short, in KeyPressed, remove the correctAnswer++; and falseAnswer++; within the key = ‚t‘ and key = ‚f‘ parts. They cause the wrong values.

Note, i couldn‘t get the Code to run on IOS, so i can‘t tell if that solves it, but i think it should, if there‘s not another issue.

1 Like