Skip to content

JarlathMacS/hangman

Repository files navigation

Hangman welcome


Hangman

This game is a Python terminal project which is, first and foremost, intended to be fun to play. Users can try to improve their own performances, and can try to better their friends'.

While the users are playing the game, they are improving their vocabulary. They are also improving their spelling skills.

Users can quickly learn the rules of the game and proceed to play. Certain messages displayed to the user remind them of certain rules.

The game can be accessed by this link

Responsive Mockup


How to play:

  1. Click this link or copy this text: https://hangman-5f3cd9b4e6da.herokuapp.com and paste it in your browser's address bar.
  2. As soon as the page is loaded, the menu is presented.
  3. Select option [2] to familiarise yourself with the rules.
  4. Select option [1] to begin playing.
  5. Follow the onscreen prompts and messages to advance through each hidden word presented.
  6. When you are ready to finish playing, select option [3] from the menu to exit the game.
  7. Don't forget to send the link to this game to your friends!

The game can be accessed by this link


User Stories

First Time Visitor Goals:

  • As a first time visitor, I want to quickly understand the program's primary purpose, so that I can learn more about it.
  • As a first time visitor, I want to navigate through the program easily, so that I can find the content.
  • As a first time visitor, I want to find the program useful for myself, so that I can meet my expectations.
  • As a first time visitor, I want to see different text colours, so I can easily read the screen.

Frequent Visitor Goals:

  • As a frequent user, I want to be able to increase my vocabulary.
  • As a frequent user, I want to be able to improve my spelling skills.
  • As a frequent user, I want to be able to compete with friends on vacabulary and spelling.

Features

  • Options screen

    • As soon as the page is loaded, the user is greeted by a welcome message.

    • Below the welcome message is a menu which presents the user with 3 options:

      1. Play game

      2. Show rules

      3. Exit

Options

  • Menu options can be selected with the arrow, j/k, or emacs (C-n/C-p) keys. When the desired option is highlighted, the enter or return key accepts the choice for the user.
  • The user can also use the shortcut keys which are the 1, 2, and 3 keys.

  • Rules screen

    • Here the users are presented with the 9 rules of this particular implementation of the hangman game.
    • Below the rules, the user can find the main menu again where they can choose another option.

Rules


  • Play game screen

    • When the users choose the option [1] to play game, they are presented with this first game screen.
    • They see 2 messages, the first telling them how many lives they have, the second showing them the hidden word.
    • The lives message is in red text with a white background, as lives are critical to the game play.
    • The number of letters in the hidden word are indicated by the same number of underscores (_). This is in green text.
    • At the bottom of the screen is the prompt for user input, asking them to guess a letter.

Play game screen


  • Correct guess screen

    • When the users guess a letter which is contained in the hidden word, they are presented with a message in green text.
    • The users are also told how many times their correctly guessed letter appears in the hidden word.
    • Their number of lives is shown again to them, which will not have changed as they just correctly guessed a letter.
    • Next is the message which keeps track of all the letters they will have guessed through the current hidden word.
    • These letters are presented in alphabetical order for ease of reference. They are in yellow text.
    • Next is the hidden word again, represented by the underscores for the letters yet to be guessed, and the correctly guessed letters also in green text.
    • The game continues through the promt for user input again, asking to guess a letter.

Correct guess screen


  • Incorrect guess screen

    • When the users guess a letter which is not contained in the hidden word, they are presented with a message in red text.
    • As a check and feedback to the user, the message repeats back the letter the user just guessed incorrectly.
    • Their number of lives is shown again to them, which will have reduced by 1 as they just incorrectly guessed a letter.
    • Next is the message which keeps track of all the letters they will have guessed through the current hidden word.
    • These letters are presented in alphabetical order for ease of reference. They are in yellow text.
    • Next is the hidden word again, represented by the underscores for the letters yet to be guessed, and the correctly guessed letters also in green text.
    • The game continues through the promt for user input again, asking to guess a letter.

Incorrect guess screen


  • Invalid guess screen

    • When the users enter a character/s other than the single 26 alphabet letters A to Z, they are presented with a message in red text.
    • As feedback to the user, the message reminds them of the rules, and assures them they have not just expended a life.
    • Their number of lives is shown again to them, which will not have reduced as they just guessed an invalid entry.
    • The game continues through the promt for user input again, asking to guess a letter.

Invalid guess screen


  • Already guessed screen

    • When the users guess a letter they have already guessed, whether correctly or not, they are presented with a message in blue text.
    • As a check and feedback to the user, the message repeats back the letter the user just guessed again. It also assures them they have not just expended a life
    • Their number of lives is shown again to them, which will not have reduced as they just guessed a repeated guess.
    • The game continues through the promt for user input again, asking to guess a letter.

Already guessed screen


  • Died screen

    • If the users lose all 6 of their lives, they are presented with a message in red text with a white background, informing them they have no lives remaining and so 'have died'.
    • The answer to the hidden word is presented in green text with white background, as feedback to the user and for their learning.
    • Below the answer, the user can find the main menu again where they can choose to play again, revisit the rules, or exit.

Died screen


  • Lived screen

    • If the users correctly guess all the letters in the hidden word before losing all 6 of their lives, they are presented with a message in green text congratulating them, and showing the answer word with a white background, to confirm their guesses.
    • Below the answer, the user can find the main menu again where they can choose to play again, revisit the rules, or exit.

Lived screen


  • Exit screen

    • If the users select the exit option [3] from the main menu, they are presented with a message in magenta thanking them for playing.

Exit screen


Technologies Used

Languages:

Frameworks/Libraries, Programmes and Tools:

Python modules/packages:

Standard library imports:
  • os was used to clear the terminal while running the program.
  • random was used to implement pseudo-random number generation.
  • string was used to determine the valid acceptable characters.
  • time.sleep was used to delay the screen by seconds.
Third-party imports:

Other tools:

  • GitPod was used as the main tool to write and edit code.
  • GitHub was used to host the code and for version control.
  • Heroku.com was used to deploy the project.

Bugs

  • Unsolved bugs
    • A 'TypeError: list indices must be integers or slices, not NoneType' exception is raised when the Escape key is used during the main menu

Testing

The application was tested continuously during its development.

Validators

No errors were found:

  • run.py

Python Validator Python Validator

  • words.py

Python Validator


Deployment

  • The application was deployed through Heroku
  • The application can be accessed at the link

To deploy the application to Heroku so it can be run as a remote web application:

  • Clone the repository:

    1. Open a folder on your computer with the terminal.
    2. Run the following command
    • git clone https://github.com/JarlathMacS/hangman.git
    1. Create your own GitHub repository to host the code.

    2. Run the command git remote set-url origin <Your GitHub Repo Path> to set the remote repository location to your repository.

    3. Push the files to your repository with the following command: git push

    4. Create a Heroku account if you don't already have one here Heroku.

    5. Create a new Heroku application on the following page here New Heroku App:

      • New Heroku App
    6. Go to the Deploy tab:

      • Deploy Tab

      • Deployment Method

    7. Link your GitHub account and connect the application to the repository you created.

      • Link GitHub account
    8. Go to the Settings tab:

      • Settings Tab
    9. Click "Add buildpack":

    10. Add the Python and Node.js buildpacks in the following order:

      • Add Python and Node.js
    11. Go back to the Deploy tab:

      • Deploy Tab
    12. Click "Deploy Branch":

      • Deploy Branch

      • Wait for the completion of the deployment.

      • Deploying Branch

    13. Click "View app" to launch the application inside a web page.

Credits

Acknowledgements

Iuliia Konovalova

I am very grateful to my mentor Iuliia Konovalova for her direction and feedback

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors