The classic word game has player to guess the letters to a secret word. For each incorrect letter, the picture of hangman is slowly drawn. Try to guess the complete word before the hangman completes.
Making Hangman Game
- Define the game category as Animal and list of WORDS.
- Create the HANGMAN_PICS drawing.
- Define drawHangman function to check for missed Letters, correct Letters and secret Word.
- Display the CATEGORY
- If there is missing missed Letters, display missing letter.
- Next, display the correct Letters together with “_”.
- Define getPlayerGuess function is to ask for user to input for their guess.
- It check if the input guess is already guessed before
- It must be a single word.
- In the main function, we had the drawHangman function first.
- Ask for user to guess, check the guess word in secret Word.
- If it is part of secret Word, then correct Letters will be kept.
- For all the secret Word, is there found in all correct Letters.
- If Yes, then we print “You have won!”
- If No, missed Letters will be updated and check if the missed Letters is maximum to the HANGMAN_PICS, then show “You have run out of guess”
Finally, let have a guess game maybe you want to have a group of friends to play American game show Wheel of Fortune.
Thanks for reading and enjoy your day.