Giter VIP home page Giter VIP logo

python-game's Introduction

Python Hangman Game

headshot

Live link: https://thawing-hamlet-48348.herokuapp.com/

Table of Contents

  1. Goals
    1. Organisational Goals
    2. User Stories
  2. Development
    1. Strategy
    2. Planning
    3. Flowcharts
  3. Upgradability
  4. Functions
  5. Heckling
  6. Testing
    1. Functional Testing
    2. Validator Testing
  7. Issues
    1. Unfixed Bugs
    2. Improvements
  8. Credits

Goals

Organisation Goals

  • As a creator I want to portray a game that flows smoothly
  • As a creator I want to let the player choose between difficulties
  • As a creator I want to make sure the player enjoys their game

User Stories

  1. As a user I want to easily know the rules of the game
  2. As a user I want to easily understand how to start the game
  3. As a user I need to know what my score is
  4. As a user I need to know when the game has been won

Development Plane

The end goal is to create a smooth-running game that lets the player with ease dive into the world of word-guessing.

The key is to well prepared follow the flowchart in order to answer one function at a time.

Strategy

The strategy is to create a clear and funny game based on the classic Hangman with a few twists. The twists being a scary/vindictive/halloween-ey theme. In order to complete the game the user stories had to be answered.

Planning

The planning phase was made in stages, starting off with a generalised overview and then advancing into specifics. Considering it's a terminal game no wireframes were needed and used mainly flowcharts to plan.

Flowcharts


The over-all birds-eye view of the game is as below, in which you'll find the general flow of the game:
General Flowchart

general-flowchart


Upgradability

The puppetmaster behind the game - in order to make the game easily upgradable with difficulties i added a hangman class which controls it:

Class Flowchart

class-flowchart


In order to upgrade the game with more wordslists or difficulties all that was needed was to make the list and apply it in the parameter of the intended difficulty in the code.

Example:

if choice == 'EASY':
            startGame(wordsL1, HANGMANPICS_EASY, name)
        elif choice == 'HARD':
            startGame(wordsL2, HANGMANPICS_HARD, name)

This means if you'd like to add another difficulty, let's say "INSANE" all you have to do is:

  1. Add a wordsL3 list of whatever words you want in the INSANE-difficulty
  2. Add whatever imagery (HANGMANPICS), e.g removing or adding levels, and name it HANGMANPICS_INSANE
  3. Extend the above code with to:
if choice == 'EASY':
            startGame(wordsL1, HANGMANPICS_EASY, name)
        elif choice == 'HARD':
            startGame(wordsL2, HANGMANPICS_HARD, name)
        elif choice == 'INSANE':
            startGame(wordsL3, HANGMANPICS_INSANE, name)

Or another one:

  1. Add a wordsL4 list of whatever words you want in the IMPOSSIBLE-difficulty
  2. Add whatever imagery (HANGMANPICS), e.g removing or adding levels, and name it HANGMANPICS_IMPOSSIBLE
  3. Extend the above code with to:
if choice == 'EASY':
            startGame(wordsL1, HANGMANPICS_EASY, name)
        elif choice == 'HARD':
            startGame(wordsL2, HANGMANPICS_HARD, name)
        elif choice == 'INSANE':
            startGame(wordsL3, HANGMANPICS_INSANE, name)
        elif choice == 'IMPOSSIBLE':
            startGame(wordsL4, HANGMANPICS_IMPOSSIBLE, name)

Functions

The ability to enter your name, which personalizes the experience of the game:

functions-name

Immediately after you input your name, the rules of the game are displayed, as well as the ability to always be able to type "exit" if you should want to quit the game: (User stories: 1. As a user I want to easily know the rules of the game)

functions-rules

In order to start the game, one is asked whether they want it Easy or Hard: (User stories: 2. As a user I want to easily understand how to start the game)

functions-difficulty

After choosing, the game starts, and instantly lets the player know the amount of lives, the fact that the guessed letters will be saved for them, and where to enter their letter: (User stories 1/3: As a user I want to easily know the rules of the game/As a user I need to know what my score is)

functions-start

In order to let the player know they've guessed the word incorrectly, the lives will go down as well as print the wrongly put letter in "Tried letters/words":

functions-incorrect

While the player tries to guess an entire word a warning pops up letting the user know that if they decide to be brave, they might lose a life:

functions-word

In order to let the player know they've guessed the word correctly and won, before running out of lives, the below function will display: (User stories: 4. As a user I need to know when the game has been won)

functions-win

In order to let the player know they've ran out of lives and lost the game. The user is also made aware of the actual word, as well as being able to play again:

functions-loss

Heckling

Or the nicer phrasing "interaction with the player" - which is a key part of playing any game, more so in a python terminal game where the gaming experience is quite linear. So in order to bring the game alive I've added interaction in three steps:

Three lives remaining:

functions-heckle1

Two lives remaining:

functions-heckle2

One life remaining:

functions-heckle3

Lastly, a complete run-through of the game:

run-through-readme.mov

Testing

Functional testing

See details here

Validator Testing

Pep8 validator testing:

Validator Python

validator-python

Issues

  • Firstly I started writing the code for the game but realised quickly I wouldn't be able to make it upgradable, thus choosing to rethink the project and came up with classes.

  • Too many print statements in order to stay within the lines. Solution was the below code, to allow new lines in one statement:

print("Many have come, none have left.",
          "\nWhat makes you think you will be",
          "the first to defeat the Skull of Kol'dan?")
  • Finding a way to match the guessed letter with the actual word in a simple way, which introduced the hidden word compared to plain text - being able to compare with plain text while keeping the hidden word hidden:
    return [i for i, ltr in enumerate(game.plain_text) if ltr == guess]

Unfixed Bugs

None to my recollection.

Improvements

  • Be able to keep highscores
  • Allow people to save previous scores
  • Add a "hint" function at the last life.

Deployment

GitHub:

  • The site was deployed to GitHub pages. The steps to deploy are as follows:
    • In the GitHub repository, navigate to the Settings tab
    • From the source section drop-down menu, select the Master Branch
    • Once the master branch has been selected, the page will be automatically refreshed with a detailed ribbon display to indicate the successful deployment.

Heroku:

  1. Create an account with Heroku
  2. Create a new app whilst logged in
  3. Add Buildpacks 'Python' and 'NodeJS'
  4. Connect your GitHub repository via "Connect to GitHub"
  5. Enable either "Automatic Deploys" or do it manually.

Credits

Media

python-game's People

Contributors

imgbotapp avatar marcroth0 avatar

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.