Hangman!!
Requirements:
- There should be a predefined array of words from which a word will randomly be chosen when the game starts. You can decide what all words to include in that list.
- Every time, before you ask for the user to guess (input) a letter (character), you should display underscores to show letters that have not been guessed yet.
- You should also show the number of remaining lives(start with 6 lives, lose one life with each incorrect guess)
- If the inputted character is in the word, then the user's remaining lives shouldn't reduce, and the appropriate underscores should be replaced by the correctly guessed letter.
- If the inputted character is not in the word, then the user's remaining lives should reduce by 1, and none of the underscores should be replaced.
- There should be a check to ensure that the entered character is a letter and not a digit or a special character. If the user inputs any one of them, then he/she should be prompted again to input a valid character.
- The game should end when the user correctly guesses the word or when the user's remaining lives becomes zero. The final message can thus either be “You Won!!” or “You Lost...better luck next time”.
Code requirements:
- Must have at least 1 function of your own
- Must use at least 1 loop(while or for) and 1 conditional
- Must tell what is going on(ask for input, tell that a life was lost etc.)
Don't understand? Look at one of the demo videos on the discord server! If you haven't joined it yet, join it now!
-----FOR BONUS CHALLENGE ONLY-----
Hangman 2.0
Requirements:
- Store all of the previous guesses the user has made, and inform the user if he/she guesses the same letter twice. Don't penalize for guessing the same letter twice; instead, the user should be prompted to enter a different letter.
- Draw a the hangman before every prompting the user to input a character alongside the word to guess and the remaining lives
- Add body parts to the hangman drawing(head first, then one hand, then other hand, then body, then one leg and lastly other leg) each time an incorrect guess is input
- After the game is over, ask the user if he/she wants to play again. If the response is yes, then reset the game (randomly pick a new word from the list of words. Make sure that the new word chosen isn't the same as the previous word) and start the game. If the response is no, then end the program.
Don't understand? Look at one of the demo videos on the discord server! If you haven't joined it yet, join it now!