diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 7db0052..799ceba 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -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]); } \ No newline at end of file diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index 1a66ecb..a258422 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -7,6 +7,6 @@ char* getWordFromList(int); bool wordGuessed(char[],char[]); bool letterGuessed(char, char[], int, char[]); void changeLetter(char, char[], int, char[]); -void drawHangman(); +void drawHangman(int); #endif