This project is a simple Hangman game implemented in C# using the console. The player tries to guess a word by entering letters one at a time. For each incorrect guess, a part of the hangman is drawn on the console. The game continues until the player guesses the word correctly or makes too many incorrect guesses.
- Run the program.
- The game will display a random word as a series of underscores, representing the letters to be guessed.
- Enter a letter as your guess and press Enter.
- If the letter is correct and appears in the word, it will be revealed in the word display.
- If the letter is incorrect, a part of the hangman will be drawn, indicating the number of incorrect guesses made.
- Repeat steps 3-5 until either the word is fully revealed or the hangman is complete.
- The game ends when the word is guessed correctly or the hangman is complete.
- The final result is displayed, indicating whether the player won or lost.
The project consists of a single file:
Program.cs
: Contains the main logic of the Hangman game, including functions for drawing the hangman, printing the word with guessed letters, and handling user input.
This project does not have any external dependencies. It uses the built-in functionalities of the C# language and the .NET framework.
To run the project, follow these steps:
- Set up a C# development environment (e.g., Visual Studio, Visual Studio Code with .NET SDK).
- Create a new C# project.
- Replace the contents of the
Program.cs
file with the provided code. - Build and run the project.
To customize the Hangman game, you can modify the following parts of the code:
wordDictionary
: The list of words that the game randomly selects from. You can add or remove words as desired.- The hangman ASCII art: You can modify the
printHangman
function to change the drawing of the hangman based on the number of incorrect guesses. - The game introduction and ending messages: Modify the messages displayed using
Console.WriteLine
in theMain
method.
Feel free to experiment and enhance the game according to your preferences!
This project is licensed under the MIT License.
Credits to Shaun Halverson.