Browse Source

Hinzufügen der ASCII-Art für die Hangmanfigur + Kontrolle durch übergangsfunktion drawHangman

remotes/origin/tim
fdai7727 11 months ago
parent
commit
e4def0a3a2
  1. 63
      src/main/c/Tim/hangman.c
  2. 1
      src/main/c/Tim/hangman.h

63
src/main/c/Tim/hangman.c

@ -16,6 +16,58 @@ char wordlist[LISTSIZE][MAX_WORD_LENGTH] = {
"Fernbedienung", "Computertastatur" "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() void hangman()
{ {
@ -57,7 +109,10 @@ void hangman()
break; break;
} }
letterGuessed(userSelection, guessWord, length, displayWord);
if(!letterGuessed(userSelection, guessWord, length, displayWord))
{
drawHangman();
}
changeLetter(userSelection, guessWord, length, displayWord); changeLetter(userSelection, guessWord, length, displayWord);
printf("%s\n", 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]);
} }

1
src/main/c/Tim/hangman.h

@ -7,5 +7,6 @@ char* getWordFromList(int);
bool wordGuessed(char[],char[]); bool wordGuessed(char[],char[]);
bool letterGuessed(char, char[], int, char[]); bool letterGuessed(char, char[], int, char[]);
void changeLetter(char, char[], int, char[]); void changeLetter(char, char[], int, char[]);
void drawHangman();
#endif #endif
Loading…
Cancel
Save