Game Development Reference
In-Depth Information
same word return from getRandomWord() twice in a row, but this is just a
coincidence.
146. else:
147. break
If the player typed in 'no' when asked if they wanted to play again, then they return
value of the call to the playAgain() function would be False and the else-block
would have executed. This else-block only has one line, a break statement. This causes
the execution to jump to the end of the loop that was started on line 112. But because there
is no more code after the loop, the program terminates.
Making New Changes to the Hangman Program
This program was much bigger than the Dragon Realm program, but this program is also
more sophisticated. It really helps to make a flow chart or small sketch to remember how
you want everything to work. Take a look at the flow chart and try to find the lines of code
that represent each block.
At this point, you can move on to the next chapter. But I suggest you keep reading on to
find out about some ways we can improve our Hangman game.
After you have played Hangman a few times, you might think that six guesses aren't
enough to get many of the words. We can easily give the player more guesses by adding
more multi-line strings to the HANGMANPICS list. It's easy, just change the ] square
bracket on line 58 to a ,''' comma and three quotes (see line 57 below). Then add the
following:
58. ==========''', '''
59.
60. +----+
61. | |
62. [O |
63. /|\ |
64. / \ |
65. |
66. ==========''', '''
67.
68. +----+
69. | |
70. [O] |
71. /|\ |
72. / \ |
73. |
74. ==========''']
Search WWH ::




Custom Search