Exercise: Number guessing game
- Create a file called number_guessing_game_0.cr
- Using the random module the computer "thinks" about a whole number between 1 and 20.
- The user has to guess the number. After the user types in the guess the computer tells if this was bigger or smaller than the number it generated, or if was the same.
- The game ends after just one guess.
- Create a file called number_guessing_game_1.cr
- The user can guess several times. The game ends when the user guessed the right number.
- Create a file called number_guessing_game_2.cr
- If the user hits 'x', we leave the game without guessing the number.
- Create a file called `number_guessing_game_3.cr
- If the user presses 's', show the hidden value (cheat)
- Create a file called number_guessing_game_4.cr
- Soon we'll have a level in which the hidden value changes after each guess. In order to make that mode easier to track and debug, first we would like to have a "debug mode".
- If the user presses 'd' the game gets into "debug mode": the system starts to show the current number to guess every time, just before asking the user for new input.
- Pressing 'd' again turns off debug mode. (It is a toggle each press on "d" changes the value to to the other possible value.)
- Create a file called number_guessing_game_5.cr
- The 'm' button is another toggle. It is called 'move mode'. When it is 'on', the hidden number changes a little bit after every step (+/-2). Pressing 'm' again will turn this feature off.
- Create a file called number_guessing_game_6.cr
- Let the user play several games.
- Pressing 'n' will skip this game and start a new one. Generates a new number to guess.