So I've got a game that when I run it, begins by calling the function menu()
. For some reason it won't take the input and correctly go the to next step. Any ideas?
void menu() {
char x = -1;
while (x != '3') {
cout << "\n";
cout << "\n";
cout << "\n---------------------";
cout << "\n Main Menu ";
cout << "\n 1 - Start a New Game";
cout << "\n 2 - Instructions ";
cout << "\n 3 - Exit Game ";
cout << "\n---------------------";
cout << "\n";
cout << "\n";
cout << "\n Enter Selection:";
cin >> x;
switch (x) {
case '1':
for(i=0; i<15;i++){
cout<<"\n"
}
playgame();
break;
case '2':
for(i=0; i<15;i++){
cout<<"\n"
}
instructions();
break;
case '3':
for(i=0; i<15;i++){
cout<<"\n"
}
cout << "Good bye\n" << endl;
break;
default:
cout << "Invalid Character\n";
cout << "\n";
cout << "Press Space to continue\n";
}
for(i=0; i<15;i++){
cout<<"\n"
}
}
}
I changed it up so it just clears the screen by using a for loop and "\n". But now it doesn't hit the next line for some reason.
EDIT, now my menu() isn't working. It's asking for the input, then hitting the for loop to clear, then never does the next line. Am I passing the input incorrectly? Or something else?