I have my code for keypress here. What I’m looking for is a way to prevent the code from jumping straight from “isGameStart” to “isGameS1”. So that it requires you to hit the ENTER key again.
void keyReleased()
{
if (keyCode == ENTER && isGameStart)
{
isGameStart = false;
isInstructions = true;
}
if (keyCode == ENTER && isInstructions)
{
isInstructions = false;
isGameS1 = true;
}
}
I assume isGameS1 is actually isInstructions, right? In any case, you need to use if else, not just if.
How if Else works :
//this happens all during one frame!
if (true) {//this is executed}
if (true) {
//this is executed
} else { //this is not}
if (false) {
//this is not
} else if (false) {
//this is not
} else if (false) {
//this is not
} else { //this is executed}
if (false) {
//this is not
} else if (true) {
//this is executed
} else if (true) { //this is not even checked, since we already found a true condition before
//this is not!!!
}
I prefer the if-else here. If you were to re-arrange the code in the future, this bug will return. When you read the code, you should see the connection and dependency.