Created
July 22, 2016 12:02
-
-
Save richardbwest/46a646720717700277bb40cf2148516b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,random | |
#Global variables and lists to be used throughout my program. | |
wordsList = ["dog","cat","mouse","hyena"] | |
usedLetters = [] | |
chosenWord = random.choice(wordsList) | |
lives = 6 | |
stickmen = [ | |
"\ | |
|------\n\ | |
| O\n\ | |
| ---|---\n\ | |
| / \\ \n\ | |
| / \\ \n\ | |
|_____", | |
"\ | |
|------\n\ | |
| O \n\ | |
| ---|---\n\ | |
|\n\ | |
|\n\ | |
|_____", | |
"\ | |
|------\n\ | |
| O\n\ | |
|\n\ | |
|\n\ | |
|\n\ | |
|_____", | |
"\ | |
|------\n\ | |
|\n\ | |
|\n\ | |
|\n\ | |
|\n\ | |
|_____", | |
"\ | |
|\n\ | |
|\n\ | |
|\n\ | |
|\n\ | |
|_____", | |
"\n\n\n\n______", | |
"\n\n\n\n\n", | |
] | |
def mainScreen(): | |
os.system('clear') | |
print("Welcome to the Hangman game\n\n") | |
drawStickMan() # Draw the stick man | |
print("\n\n") | |
drawTheWord() | |
print("\n\n") | |
showUsedLetters() | |
print("\n\n") | |
getALetter() | |
def drawStickMan(): | |
print(stickmen[lives]) | |
def drawTheWord(): | |
print("I'm the word with blanks") | |
def showUsedLetters(): | |
print("Looking I'm drawing the used letters") | |
def getALetter(): | |
global lives | |
global usedLetters | |
letter = input("please enter a letter") | |
if not len(letter) == 1: | |
mainScreen() | |
elif not letter.isalpha(): | |
mainScreen() | |
elif letter in usedLetters: | |
mainScreen() | |
else: | |
usedLetters.append(letter) | |
if not letter in chosenWord: | |
lives = lives - 1 | |
mainScreen() | |
mainScreen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment