|
@ -104,20 +104,20 @@ void hangman() |
|
|
} |
|
|
} |
|
|
printf("\n\n%s\n", displayWord); |
|
|
printf("\n\n%s\n", displayWord); |
|
|
|
|
|
|
|
|
while(!wordGuessed(guessWord, displayWord)) |
|
|
|
|
|
|
|
|
while(1) |
|
|
{ |
|
|
{ |
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
printf("Bitte gib einen Buchstaben ein!\n"); |
|
|
scanf(" %c", &userSelection); |
|
|
scanf(" %c", &userSelection); |
|
|
if(userSelection == '0') |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!letterGuessed(userSelection, guessWord, length)) |
|
|
if(!letterGuessed(userSelection, guessWord, length)) |
|
|
{ |
|
|
{ |
|
|
countWrongGuess++; |
|
|
countWrongGuess++; |
|
|
printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-countWrongGuess); |
|
|
printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-countWrongGuess); |
|
|
} |
|
|
} |
|
|
|
|
|
if(userSelection == '0'||wordGuessed(guessWord, displayWord)||noTrysLeft(countWrongGuess)) |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
changeLetter(userSelection, guessWord, length, displayWord); |
|
|
changeLetter(userSelection, guessWord, length, displayWord); |
|
|
drawHangman(countWrongGuess); |
|
|
drawHangman(countWrongGuess); |
|
|
printf("\n\n%s\n", displayWord); |
|
|
printf("\n\n%s\n", displayWord); |
|
@ -152,7 +152,6 @@ bool wordGuessed(char x[], char y[]) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool letterGuessed(char x, char y[], int length) |
|
|
bool letterGuessed(char x, char y[], int length) |
|
|
{ |
|
|
{ |
|
|
int counter = 0; |
|
|
int counter = 0; |
|
@ -185,7 +184,6 @@ bool letterGuessed(char x, char y[], int length) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void changeLetter(char x, char y[], int length, char ptr[]) |
|
|
void changeLetter(char x, char y[], int length, char ptr[]) |
|
|
{ |
|
|
{ |
|
|
for(int i = 0; i<length; i++) { |
|
|
for(int i = 0; i<length; i++) { |
|
@ -222,4 +220,17 @@ void changeLetter(char x, char y[], int length, char ptr[]) |
|
|
void drawHangman(int x) |
|
|
void drawHangman(int x) |
|
|
{ |
|
|
{ |
|
|
printf("%s", hangmanStages[x]); |
|
|
printf("%s", hangmanStages[x]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool noTrysLeft(int x) |
|
|
|
|
|
{ |
|
|
|
|
|
if(x == 6) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("Du hast verloren!\n\n"); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |