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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <string>
#include <windows.h>
#include <ctime>
using namespace std;
#include <process.h>
void gotoxy(short x, short y)
{
COORD pos={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void menu()
{
int num, l;
string g;
system("color 07");
cout<<"\n\n\n\n\t\t\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb";
cout<<"\n\t\t\xdb\t\t\t\t\t\xdb\n\t\t\xdb\t\t\t\t\t\xdb";
cout<<"\n\t\t\xdb\t [1] New Game\t\t\xdb"<<endl;
cout<<"\t\t\xdb\t [2] Instructions\t\t\xdb"<<endl;
cout<<"\t\t\xdb\t [3] Exit\t\t\t\xdb"<<endl;
cout<<"\t\t\xdb\t\t\t\t\t\xdb\n\t\t\xdb\t\t\t\t\t\xdb";
cout<<"\n\t\t\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb";
}
void inst()
{
int num, g, l;
cout<< "\n\t\t\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\t\ How to Play ..\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\tIn order to play the game, \xdb";
cout<< "\n\t\t\xdb follow these simple steps :)\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\tMAIN GOAL OF THE GAME..\t\t \xdb";
cout<< "\n\t\t\xdb\tThere will be words hidden in *, \xdb";
cout<< "\n\t\t\xdb you should guess it with only THREE (3)\xdb";
cout<< "\n\t\t\xdb TRIALS.\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\tJust key in a letter for you to \xdb";
cout<< "\n\t\t\xdb know if the word is included, think \xdb";
cout<< "\n\t\t\xdb carefully to complete the word.\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\tIf you fail to input the correct \xdb";
cout<< "\n\t\t\xdb letter, the game is OVER!\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\t\t\t\t\t \xdb";
cout<< "\n\t\t\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb";
cout<< "\n\t\t\t\t[Enter]";
while ((l= getch()) != 13)
printf ("[ENTER]\n", l);
}
const int maxGuesses = 3;
int main (int argc, char *argv[])
{
enum fields {WORD, HINT};
string words[8][2] = {
{"courtney", "3W8L"},
{"jersey", "DESPICABLE GUY"},
{"sam", "TALK BACK"},
{"top", "LUCKY 13 LEADER"},
{"kevin", "SANTOS"},
{"kean", "PATRICK"},
{"red", "TOP'S BESTFRIEND"},
{"michie", "SAM'S BESTFRIEND"}
};
int num, g, l;
menu();
do
{
CHOICE:
gotoxy(22,15);cout<<"Choose a number to continue: ";
gotoxy(51,15);std::cin>>num;
if (num>=4)
{
gotoxy(51,15);cout<<" ";
gotoxy(10,17);cout<<"Please enter a 'Valid Value within the range [1-3]'!!";
Sleep(500);
gotoxy(10,17);cout<<" ";
}
} while (num>=4);
switch (num)
{
case 2:
{
inst();
system ("cls");
menu();
goto CHOICE;
}break;
case 3:
{
system ("cls");
int g;
cout<<"Are you sure you want to exit the game?";
cout<<"\n\t[1]Yes or [2]No : ";
std::cin>>g;
if (g==1)
{
cout<<"Thank You for using the program. Bye :D\n";
cout<<"please press [ENTER] to exit.";
}
else
{
system ("cls");
menu();
goto CHOICE;
}
}break;
}
if (num==1)
{
system ("cls");
GAME:
bool done=true;
char again;
do{
int wrongGuessCount;
string in, a;
srand(time(0));
int i = rand() % 5;
string myword = words[i][WORD];
string myhint = words[i][HINT];
cout << " HINT : " << myhint << "\n";
string guess(myword.size(),'*');
wrongGuessCount = 0;
while ((wrongGuessCount < maxGuesses) && (guess != myword)){
cout << " Guess word : " << guess << "\n";
getline(cin, in);
if (myword.find(in[0]) != string::npos) {
for (size_t pos = 0;(pos = myword.find(in[0], pos)) != string::npos; pos++){
guess[pos] = in[0];
}
}else{
++wrongGuessCount;
}
}
if (myword == guess) {
cout << "The word is : " << myword << "\n";
cout << "CONGRATULATIONS!";
}else{
cout << "GAME OVER but the word is : " << myword <<"\n";
done=false;
}
cout << "Do you want to play again? [Y/N]: "; cin >> again;
}while (done);
switch (again)
{
case 'y':
{
goto GAME;;
} break;
case 'n':
{
system ("cls");
menu();
goto CHOICE;
}
}
system ("pause");
return 0;
}
}
|