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
|
PART TWO
void diff_select(int user_difficulty)
{
char hidden_word[11]={0};
char select_word[11]={0};
cin.ignore();
int exit_1 = 0;
display_intro02();
cout << "Good selection!\n To play, you must first choose a difficulty\n";
cout << "Please type a number between 1 and 5. 5 being the hardest, 1 being the easiest.\n";
cout << "Please enter your selection\n";
//diff_check();
cin >> user_difficulty;
switch (user_difficulty)
{
case 1: game(hidden_word, select_word);
Sleep(2000);
break;
case 2: game (hidden_word,select_word);
Sleep(2000);
break;
case 3: game (hidden_word, select_word);
Sleep(2000);
break;
case 4: game (hidden_word, select_word);
Sleep(2000);
break;
case 5: game (hidden_word, select_word);
Sleep(2000);
break;
}
}
void game(char hidden_word[], char select_word[], int user_difficulty)
{
char diff_1[5][26] = {"names","great","three","white","music"};
char diff_2[5][31] = {"accept", "booked", "desert", "gassed", "gallop"};
char diff_3[5][36] = {"acrobat", "defiant", "gullies", "library", "nuttier"};
char diff_4[5][41] = {"airbrush", "chunkier", "drunkest", "indulges", "mixtures"};
char diff_5[5][49] = {"actionless", "cartooning", "descendent", "fistcuffs", "penthouse"};
int array_size = 0;
int null_found = 0;
srand(time(0));
int rand_number = rand()%5;
if(user_difficulty == 1)
{
strcpy(hidden_word,&diff_1[rand_number][0]);
}
else if(user_difficulty == 2)
{
strcpy(hidden_word,&diff_2[rand_number][0]);
}
else if(user_difficulty == 3)
{
strcpy(hidden_word,&diff_3[rand_number][0]);
}
else if(user_difficulty == 4)
{
strcpy(hidden_word,&diff_4[rand_number][0]);
}
else if(user_difficulty == 5)
{
strcpy(hidden_word,&diff_5[rand_number][0]);
}
int len=strlen(hidden_word);
for(int i = 0; i <len; i++)
{
select_word[i]='*';
}
cout << "\nYour word is" << array_size << " Letters long." << select_word << endl;
int life = 5;
bool you_win = false;
while( (life > 0) && (you_win == false) )
{
cout<<"Current Word :" <<select_word << endl;
cout<<"Enter Letter guess: ";
char guess;
cin>>guess;
int hit=0;
for(int i=0; i<len; i++)
{
if( guess == hidden_word[i] )
{
hit++;
select_word[i] = guess;
if(strcmp(hidden_word,select_word) == 0)
{
you_win = true;
}
}
}
if(hit == 0)
{
life--;
}
}
if( (life == 0) && (you_win == false) )
{
cout<<"Loser\n";
}
if( (life > 0) && (you_win == true) )
{
cout<<"Winner\n";
}
}
|