Guess the Word
This is a game where the player must guess a secret word.
For each wrong guess the program adds to the figure: (凸 ಠ 益 ಠ)凸
The player can only guess wrong 7 times before the game ends. (the number of characters in the figure)
Before you start read through the advice on how to start and the more comfortable sections to see what the basic and advanced versions of the game include.
The first version of this game you can have a single, hard-coded secret word-
The data structure you need to represent the game that guesses each individual letter in a word is an array of individual letters.
This will allow you to guess letters and find each letter guessed and the position of those letters in the word.
A word array would look like this:
var word = ['c','a','t'];.
When the user guesses a letter, you have to have the program look through the word array and determine if the user guessed correctly. "Looking through" means looping over the word array and comparing it to the letter the user has inputted.
When the user guesses there are two possibilities:
- 1.The user guesses incorrectly. Add a character to the figure that marks when they lose the game.
- 2.The user guesses correctly, add the letter to the word they are trying to complete.
(In the first version you can just do basic output like how many guesses the user has left, and how many letters they have correct.)
After verifying the user guess, check for the state of the entire game:
If the user has guessed all the letters in the word, tell them they have won.
If the user has completed the figure tell them they lost.
When the user types a correct guess show the correct guess in the location of the secret word. Show the number of letters in the secret word.
Add different modes to the game. Change the secret word to a word with the same letter more than once.
The easy mode is when the word is like "guess" and the user guesses 's', then the game fills in both 's'.
The hard mode is where the user has to guess each letter.
Let the user enter their name at the beginning of the game.
Add a list of words to the game. When it starts the game selects one random word.
When the user has played one game with one word, allow them to continue playing with another word.
Please only refer to the reference solution after you have attempted the project. Thank you!
Note that there are many ways to implement the project and the reference solution is only 1 way.