Jul 17, 2016 at 1:24pm Jul 17, 2016 at 1:24pm UTC
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.
Here is my code:
//Hangman
#include <iostream>
#include <string>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void cls()
{
cout << string(1000, '\n');
}
int main()
{
int a=0;
int options=3;
char letter;
string word;
cout<<"\t\t\t\t"<<"++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BBBBBBBB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BBBBBBBB BBBB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BB BB BBBB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BBBBBB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<"++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<< "\t\t\t\t\t" << "--------------------" << endl;
cout<< "\t\t\t\t\t" << "| 1. Single Player |" << endl;
cout<< "\t\t\t\t\t" << "| 2. Two PLayer |" << endl;
cout<< "\t\t\t\t\t" << "| 3. Quit |" << endl;
cout<< "\t\t\t\t\t" << "--------------------" << endl;
cout<< "\t\t\t\t\t" << "Selected : ";
cin>>a;
while (a<1 || a>2)
if (a=3)
{
return 0;
}
cls();
getch();
return 0;
}
Help me please this is my project..
Last edited on Jul 17, 2016 at 1:50pm Jul 17, 2016 at 1:50pm UTC
Jul 17, 2016 at 2:07pm Jul 17, 2016 at 2:07pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#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
Last edited on Jul 17, 2016 at 2:08pm Jul 17, 2016 at 2:08pm UTC
Jul 17, 2016 at 2:12pm Jul 17, 2016 at 2:12pm UTC
Thank you very much!!! ... But what if there are three options, like mine?
Last edited on Jul 17, 2016 at 2:16pm Jul 17, 2016 at 2:16pm UTC
Jul 17, 2016 at 2:18pm Jul 17, 2016 at 2:18pm UTC
Then just add more cases.
Jul 17, 2016 at 2:28pm Jul 17, 2016 at 2:28pm UTC
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 :)
Last edited on Jul 17, 2016 at 2:28pm Jul 17, 2016 at 2:28pm UTC
Jul 17, 2016 at 2:49pm Jul 17, 2016 at 2:49pm UTC
http://www.cplusplus.com/forum/beginner/194394/