diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 8b7db3b..76b825c 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -16,6 +16,58 @@ char wordlist[LISTSIZE][MAX_WORD_LENGTH] = { "Fernbedienung", "Computertastatur" }; +char hangmanStages[7][100]={ + "+---+\n" + "| |\n" + "|\n" + "|\n" + "|\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "|\n" + "|\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "| |\n" + "|\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "| /|\n" + "|\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "| /|\\\n" + "|\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "| /|\\\n" + "| /\n" + "|\n" + "=========\n", + "+---+\n" + "| |\n" + "| O\n" + "| /|\\\n" + "| / \\\n" + "|\n" + "=========\n", +}; + void hangman() { @@ -57,7 +109,10 @@ void hangman() break; } - letterGuessed(userSelection, guessWord, length, displayWord); + if(!letterGuessed(userSelection, guessWord, length, displayWord)) + { + drawHangman(); + } changeLetter(userSelection, guessWord, length, displayWord); printf("%s\n", displayWord); } @@ -156,4 +211,10 @@ void changeLetter(char x, char y[], int length, char ptr[]) } } } +} + +void drawHangman() +{ + for(int i = 0; i<7;i++) + printf("%s", hangmanStages[i]); } \ No newline at end of file diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index ae68d97..1a66ecb 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -7,5 +7,6 @@ char* getWordFromList(int); bool wordGuessed(char[],char[]); bool letterGuessed(char, char[], int, char[]); void changeLetter(char, char[], int, char[]); +void drawHangman(); #endif