Skip to content
Learnearn.uk » Python Unit Home » Code a hangman game.

Code a hangman game.

Step 1 – Make a plan.

Handman plan

The first thing I always do when designing a new program for the first time is I draw up a plan of what my game is going to look like. I then come up with a list of as many variables, data structures and functions that I can think of that I might want to use in my game.

Here is my plan!

From my plan it became clear that I would need at least the following:

Variables

  • The Lives left ( lives)
  • The chosen word (chosenWord)

Data Structures

  • A List of possbile words to pick from ( wordsList)
  • A list of letters that have been used
  • A list of stick men icons for each stage in the hangman hanging

Functions

  • A main screen to display the words, hangman etc (mainScreen).
  • Display the hangman graphic (drawStickMan)
  • Display the hidden word / blanks (drawTheWord)
  • Display the used words (showUsedLetters)
  • A letter input screen

From this I can already start to build the framework for my program. I start by creating the welcome screen function and the lists.