Hello I am making a word Guessing game.. I named it "BITAY" because thats what its called in our country. How can i make it go to Option 1(single player) after clicking 1 and How can i make it go to Option 2(two player) after clicking 2. I am not yet done with this project. But i have done planning for what will i put in single player and two player.
#include <iostream>
int main()
{
bool keep_going = true;
int option = 0;
do{
std::cout << "Menu: Please enter 1 or 2\n";
if(std::cin >> option)
{
switch (option)
{
case 1:
std::cout << "Option 1\n";
keep_going = true;
break;
case 2:
std::cout << "Option 2\n";
keep_going = false;
break;
default:
std::cout << "1 or 2 and no other integer!\n";
}
}
else
{
std::cout << "Wrong input. Must be an integer\n";
keep_going = true;
std::cin.clear();
std::cin.ignore(1000, '\n');
}
}while (keep_going == true);
std::cout << "Escaped to here.\n";
}
Menu: Please enter 1 or 2
qwera
Wrong input. Must be an integer
Menu: Please enter 1 or 2
1
Option 1
Menu: Please enter 1 or 2
3
1 or 2 and no other integer!
Menu: Please enter 1 or 2
2
Option 2
Escaped to here.
Program ended with exit code: 0
yeah thanks,, but do you know the code about second player mode in hangman when the 2nd player needs to look away and then the 1st player needs to guess what he type.. Just need simple codes :)