Giter Club home page Giter Club logo

hows-it-hanging's Introduction

How's it Hanging

Image of the site on different device screen sizes

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

Diagram of flow chart used to design this project

- 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

Feature Description Example
Welcome page Welcome screen Image of opening page
Name Asking for users name all characters valid to allow individuality Image of name input section
Instructions Simple game instuctions are shown to the user if selected Image of instructions menu
Attempts Screen displayed with remaining attempts this counts down with every wrong guess Image of remaining attempts
Letters Played Display of previous guesses is shown after every turn Image of the display of previous guesses
Winning Message Screen displayed when user wins Image of Winning game
Losing Message Screen displayed when user loses Image of losing game
Choice of levels Screen displayed for choice of levels. Options are 1 for easy and 2 for hard. The choice determines how many letters will be in the word. Image of difficulty selection
Hangman Images Hangman Images displayed when wrong guesses made. Image of hangman diagrams Image of hangman diagrams
Play again Screen displayed asking to play again giving the user the option to 1. go again or 2. return to the main menu Image of play again screen
Clear Terminal Terminal cleared between turns to improve overall user experience shows just one hangman on screen

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

Feature Outcome Example Pass
Name Input Validate if field is empty Image of error message if no name entered Pass
Name Input Validate if entry is valid Image valid name entered Pass
Main menu Validate if entry is valid - special character input Image of error message for invalid character entry Pass
Main menu Validate if entry is valid - letter input Image of error message for invalid letter entry Pass
Main menu Validate if entry is valid - number input Image of error message for invalid number entry Pass
Main menu Validate if field is empty Image of error for empty field Pass
Instructions Options Validate if selection is valid - option 1 image of tets for option 1 Pass
Instructions Options Validate if selection is valid - option 2 image of tets for option 2 Pass
Instructions Options Validate if field is empty Image of error message for empty field Pass
Instructions Options Validate if selection is valid - letter test Image of error message for invalid letter entry Pass
Instructions Options Validate if selection is valid - wrong number test Image of error message for invalid number entry Pass
Instructions Options Validate if selection is valid - special character test Image of error message for invalid entry Pass
Level Selection Validate if selection is valid - option 1 Image of Level 1 test Pass
Level Selection Validate if selection is valid - option 2 Image of Level 2 test > Pass
Level Selection Validate if field is empty Image of empty field test > Pass
Level Selection Validate if selection is valid - letter Image of error message for invalid letter entry > Pass
Level Selection Validate if selection is valid - Number Image of error message for invalid Number entry > Pass
Level Selection Validate if selection is valid - Special Character Image of error message for invalid character entry > Pass
Game Play Validate if selection is valid - special character test Image of error message for invalid character entry Pass
Game Play Validate if selection is valid - Number test Image of error message for invalid number entry Pass
Game Play Validate if field is empty Image of error message for empty field Pass
Game Play Validate if selection is valid - Multiple character test Images of error messages for multiple character guesses made Pass
Winning Message Validate if message is correct Message for correct guess and winning game Pass
Losing Message Validate if message is correct Message for incorrect guess and losing game Pass
Play again input Validate if selection is valid - option 1 Image for play again option 1 Pass
Play again input Validate if selection is valid - option 2 Image for play again option 2 Pass
Play again input Validate if selection is valid - letter Image for play again invalid letter entry Pass
Play again input Validate if selection is valid - number Image for play again invalid number entry Pass
Play again input Validate if selection is valid - special Image for play again invalid character entry Pass
Play again input Validate if field is empty Image for play again error message Pass
Exit Game option Validate if field is empty Image of exit message Pass

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 Image of inital validator results
Final validation testing Image of final validator results
Words.py validation testing Image of words list validator results
  • 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:
Bug Example Description Fix
Name Entry Image of Name Bug Image of Name Function Code This bug was noted during testing. The original code allowed for a space to be entered as a Name. However, this was not a valid entry as it does not print a name to the terminal. This was fixed by adding an elif statement to the code to ensure that a character needs to be entered. Image of Name fix
Numbers accepted Image of Number being accepted This bug was noted during testing of the game. It was noted that numbers were accepted as valid guesses by the user. This bug was fixed by adding the isalpha() method to the elif statement for players_turn. Image of input fix
Double Hangman Image of double hangman on terminal This bug was observed during game play that if a guess was made two hangman images were printed in error. This bug was fixed by removing the second print(hangman_status(attempts)) that was present in the code. Image of double hangman code update

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.

hows-it-hanging's People

Contributors

amydelaney94 avatar

Forkers

xuechun326

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.