|
|
@ -84,11 +84,13 @@ void hangman() |
|
|
|
{ |
|
|
|
char guessWord[MAX_WORD_LENGTH]; |
|
|
|
int length; |
|
|
|
int countWrongGuess=0; |
|
|
|
strcpy(guessWord,getWordFromList(rand() % LISTSIZE)); |
|
|
|
length = strlen(guessWord); |
|
|
|
printf("%s %d\n",guessWord, length); |
|
|
|
|
|
|
|
char displayWord[MAX_WORD_LENGTH]; |
|
|
|
drawHangman(countWrongGuess); |
|
|
|
for (int i = 0; i <= length; i++) |
|
|
|
{ |
|
|
|
if(i<length) |
|
|
@ -100,7 +102,7 @@ void hangman() |
|
|
|
displayWord[i] = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
printf("%s\n", displayWord); |
|
|
|
printf("\n\n%s\n", displayWord); |
|
|
|
|
|
|
|
while(!wordGuessed(guessWord, displayWord)) |
|
|
|
{ |
|
|
@ -113,10 +115,11 @@ void hangman() |
|
|
|
|
|
|
|
if(!letterGuessed(userSelection, guessWord, length, displayWord)) |
|
|
|
{ |
|
|
|
drawHangman(); |
|
|
|
countWrongGuess++; |
|
|
|
} |
|
|
|
changeLetter(userSelection, guessWord, length, displayWord); |
|
|
|
printf("%s\n", displayWord); |
|
|
|
drawHangman(countWrongGuess); |
|
|
|
printf("\n\n%s\n", displayWord); |
|
|
|
} |
|
|
|
|
|
|
|
}while(userSelection != '0'); |
|
|
@ -215,8 +218,7 @@ void changeLetter(char x, char y[], int length, char ptr[]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void drawHangman() |
|
|
|
void drawHangman(int x) |
|
|
|
{ |
|
|
|
for(int i = 0; i<STAGENUM;i++) |
|
|
|
printf("%s", hangmanStages[i]); |
|
|
|
printf("%s", hangmanStages[x]); |
|
|
|
} |