From e4def0a3a258310558eb52fb3f56ee90df92600d Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 20:34:49 +0100 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20ASCII-Art=20f=C3=BCr=20?= =?UTF-8?q?die=20Hangmanfigur=20+=20Kontrolle=20durch=20=C3=BCbergangsfunk?= =?UTF-8?q?tion=20drawHangman?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 63 +++++++++++++++++++++++++++++++++++++++- src/main/c/Tim/hangman.h | 1 + 2 files changed, 63 insertions(+), 1 deletion(-) 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