How's it Hanging Hangman is a word guessing game. Traditionally hangman is a game played with pen and paper and two or more people. One person picks a word and lets the others guess the letters to find the correct word. For this project I created an electronic version of this game where the user plays against the computer. This was achieved using python to select a random word from a list and check if guesses are right, wrong, already guessed or invalid. My version of the game has two levels of difficulty, easy and hard. A full description of the rules and traditional version of the game can be found here.
Table of Contents
A link to the deployed website can be found here.
Flow Chart - The logic for this project was developed through the use of flow charts using the platform Lucid Charts.
User Experience
Project Goals
- The game is easy to navigate and user friendly.
- The game to loop and allow the player to continue to play after each game.
- The game should have a choice of difficulty levels.
- It should be clear how many attempts are left in the game.
- To provide the user with an easy to find instructions section to explain how the game works.
User Stories
- As a player, I want the instructions to be easily accessible.
- As a player, I want the game to be user friendly.
- As a player, I want the game to be fun and engaging.
- As a player, I want there to be a selection of levels.
Coloured Text
- Throughout the design of the project I followed a flow chart and extended this logic to the visual design of the game. I decided to implement a simple colour scheme to improve the overall user experience.
- The colour red ("\033[0;31m) was used for errors and wrong guesses.
- The colour cyan ("\033[0;36m) was used for input lines.
- The colour green ("\033[0;32m) was used for the instruction's menu and for correct guesses.
Process Flow Chart
Lucid Charts was used to design the logic used in the development of this game.
Game Features
Future Features
- High Score Display
- A future feature that I would like to add to the app is to display high scores. This would be achieved using a Google Spreadsheet to store the number of attempts it took, or numbers of games won for each name entered. This scoreboard could then be displayed by printing the contents to the terminal.
- Level of Difficulty
- Although this game provides users with the choice of playing an Easy or Hard game, I would like to add more attempts to the Easy level to further distinguish between the two levels. This would be achieved by saving the hangman images in a new file and calling the altered Easy diagrams for the Easy game or the Standard diagrams for the Hard game.
Languages Used
Technology Used
- GitPod was used for writing code, committing, and then pushing to GitHub.
- Github was used to store the project after pushing.
- Lucid Charts was used to create and design the flow chart used in the logical design of this project.
- Am I Responsive? was used in order to see responsive design throughout the process.
- PEP8 online check was used to validate the python code.
- Heroku was used to deploy the application.
- Built-in Python Libraries
-
os -> The os library was imported to create a function to utilise the os.system to clear the terminal. This library was imported to improve the overall user experience and to ensure the terminal is clear between rounds.
-
random -> The random library was imported to access the built-in method of generating a random word from the word.py file using the "random." method.
-
sys -> The sys library was imported to create a function that allows the user to exit the game. This was achieved using the built in sys.exit() method.
-
Testing
User Stories Testing
- As a user I want the game to be easy to navigate.
- This was achieved by using the numbers 1 and 2 for Yes and No consistently throughout the game.
- As a user I want the game to loop and allow players to continue playing or exit after each round.
- This was achieved by asking player if they want to play again after each win or loss with 1 starting the game again and 2 bringing the user back to the main menu.
- As a user I want it to be clear how many attempts are left.
- This was achieved by printing the remaining attempts after each round of the game.
- As a user I want to give the user a choice of difficulty.
- This was achieved by providing the user with a choice of easy or hard difficulty levels at the start of each game.
- To provide the user with an easy to find instructions section to explain how the game works.
- This was achieved by providing an instructions option on the main menu.
Validation Testing:
Testing | Results |
---|---|
Initial validation testing | |
Final validation testing | |
Words.py validation testing |
- The code was tested using a PEP8 validator and the initial results were fixed by correcting all of the errors and warnings shown until none remained.
Bugs:
Fixed Bugs:
Deployment:
The application has been deployed using Heroku by following these steps:
Heroku was used to deploy the application.
- Commit changes and push them to GitHub.
- Go to the Heroku's website.
- Create an account or select log in.
- From the Heroku dashboard, click on "Create new app".
- Enter the "App name" and "Choose a region" before clicking on "Create app".
- Go to "Config Vars" under the "Settings" tab.
- Click on "Reveals Config Vars" and add the KEY: CREDS and the VALUE stored in creds.json file if needed.
- Add the Config Var, KEY: PORT and VALUE: 8000.
- Go to "Buildpacks" section and click "Add buildpack".
- Select "python" and click "Save changes"
- Add "nodejs" buildpack as well using the same process.
- Go to "Deployment method", under the "Deploy" tab select "GitHub" and click on "Connect to GitHub".
- Go to "Connect to GitHub" section and "Search" the repository to be deployed.
- Click "Connect" next the repository name.
- Choose "Automatic deploys" or "Manual deploys" to deploy your application.
References:
- The code used to create the images that display the hangman image to the user were adapted from youtube and github user Kiteco.
- W3Schools was used as a resource for solving syntax errors and for the isalpha() method.
- Askpython was used for the implementation of sys.exit()
- Stack Overflow was used for assistance with troubleshooting issues.
- Yawin Tutor was used for fixing syntax and coding errors that appeared throughout the coding process.
Acknowledgements
- First I would like to thank my Partner for his love and support throughout the completion of this project.
- I would also like to thank my mentor Marcel for his advice and support.
- My friends for constantly testing the project.
- Tutor Assistance for their help and support.
- Code Institute and its Slack community for their support and providing me with the necessary knowledge to complete this project.