This Python-based Hangman game enables users to guess words, categorized into different topics and difficulty levels, by iteratively selecting letters, while visually tracking incorrect guesses through ASCII hangman illustrations.
You can find the live link here: Hangman-game
- Hangman-game
- Overview
- Game Structure
- Potential future updates
- Hangman Game primary components
- Testing
- Technologies
- Bugs
- Credits
The game starts with the games logo and a welcome introduction and explanation of the game.
The Hangman game provides a word-guessing experience where a player selects a category and difficulty level, then has to identify a hidden word by suggesting letters. A partial hangman figure gets drawn with each incorrect guess, and the player is allowed up to 6 mistakes. Displayed underscores signify the word length, and a list assists in tracking previously guessed letters.
The Player wins if he guesses the word before the hangman is fully drawn; otherwise, the correct word is revealed upon loss. The Player then can choose to play again or exit the game.
- Logo and Welcome: A symbol-created logo is displayed along with a welcoming message.
- Instructions: Provides easy-to-understand instructions for how to play.
- Game Initiation: Player begins the game by pressing 'y'.
- Category Choice: Player selects a word category (foods, cars, countries).
- Difficulty Choice: Player selects a difficulty level (easy, medium, hard).
- Correct Input: Ensures the player’s input adheres to acceptable parameters (e.g., 'y' to start, valid category, and difficulty).
- Error Messaging: Informative error messages guide the player towards valid inputs.
- Word Representation: Displays underscores (_) representing the secret word's letters.
- Letter Guessing: Player attempts to reveal the word by guessing letters one at a time.
- Hangman Figure: Incorrect guesses visually build a hangman drawing and guessess become less.
- Guessed Letters: Displays a list to track and show letters the player has already guessed.
- Outcome: Reveals whether the player won or lost and shows the correct word.
- Replay Option: Presents the player with the choice to play again or exit.
Future updates for the Hangman game include better player experience through expanded and customizable word categories, the addition of user profiles and competitive leaderboards, along with a notable uplift in graphical and user interaction, moving from ASCII to a more vibrant and intuitive UI/UX.
This Hangman game allows the user to guess words from chosen categories and difficulty levels. Below are the primary components and functions utilized in the game:
Handles the selection and representation of words for the game.
- Description: Chooses a word based on the given category and difficulty.
- Parameters:
category
: The theme of the word (e.g., foods, cars, countries).difficulty
: The level of difficulty (e.g., easy, medium, hard).
- Returns: A randomly selected word from the specified category and difficulty.
- Description: Contains lists of words categorized by theme and difficulty level.
Manages the visual representation of the game.
- Description: Displays the hangman figure based on the number of incorrect tries.
- Parameters:
tries
: Number of incorrect guesses made by the player.
- Returns: A visual representation of the hangman figure for the current game state.
- Description: Outputs the game's logo and provides an explanation of how to play.
- Returns: Printed logo and game instructions.
Controls the game's main loop, logic, and interactions with the user.
- Description: The main game loop where players guess letters and the game determines the outcome based on the guesses.
- Returns: Boolean value indicating if the user wants to play another round.
- Description: Prompts the user to decide if they want to play another round.
- Returns: Boolean value (True if the user wants to play again, False otherwise).
The game prompts the user to start, choose a category, and select a difficulty level. It then engages the player in rounds of guessing letters, displaying progress, and determining the game outcome.
- Execute the program.
- Prompted to press 'y' to start the game.
y
- Hangman logo and game explanation displayed.
- Prompt to press 'y' to start the game appeared.
- Successful transition to category selection.
- Prompted to select a category (foods/cars/countries).
foods
- Successful transition to difficulty selection.
games
- Error message displayed: "Error Message: Please choose foods, cars, or countries."
- Prompted to choose word difficulty (easy, medium, hard).
easy
- Successful transition to main game loop.
extreme
- Error message displayed: "Error Message: Please choose easy, medium, or hard."
- Prompted to guess a letter.
- Enter a valid letter.
- Enter an invalid character.
- Enter multiple letters.
a
9
ab
- Feedback displayed depending on whether the letter is in the word.
- Error message displayed: "Error: Only letters allowed"
- Error message displayed: "Error: Only one letter a time allowed"
- Continue guessing letters until the word is completed or all attempts are used up.
- Upon guessing the entire word correctly, a congratulatory message is displayed.
- Upon using up all attempts without guessing the word, a message with the correct word and encouragement to try again is displayed.
- After a game finishes, player is prompted to play again.
- Choose to play again.
- Choose not to play again.
y
n
- Restarted the game.
- Displayed the message: "Thank you for playing, have a nice day! ┏( ͡ᵔ _⦣ ͡ᵔ)┛ "
- r
- Displayed the message: "Invalid input. Please enter 'y' or 'n'."
The game functions as expected, and user interactions are handled correctly.
- Languages:
- Python
- Platform:
- Heroku
When the player was asked to enter "y" to start the game the game kept looping the same question over and over.
Add != instead of === to while_start_game inside the play_hangman() function.
-
FreeCodeCamp showcased how to use Data Structures (dictionaries and lists), and also how to correctly manipulate strings (like .lower() and .strip() )
-
Reddit this subreddit has been a big help in explaining to me Modular Programming for my project.
-
Fsymbols great tool and helped me create the temporary game logo.