-
Notifications
You must be signed in to change notification settings - Fork 5
/
graphics.py
153 lines (128 loc) · 4 KB
/
graphics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
print ("________ ")
print ("| | ")
print ("| ")
print ("| ")
print ("| ")
print ("| ")
def wordCheck(word):
word = input("Enter your word: ")
word = word.upper()
length = len(word)
if (len(word)> 10 or len(word) < 3):
print("Please input a word with 3 to 10 letters.")
wordCheck(word)
else:
return(word)
def guessCheck(guess):
guess = input("Guess a letter: ")
if (len(guess) > 1):
print("Please only input one letter.")
guess = input("Guess a letter: ")
guessCheck(guess)
else:
return guess
begin = input("Would you like your word to be input or random? ")
begin = begin.upper()
word = " "
if (begin == "RANDOM"):
#Gets the number of words in Word.txt
infile = open("Word.txt", "r")
c = 0
line = infile.readline()
while line:
c += 1
line = infile.readline()
infile.close()
#Gets a random word from Word.txt
import random
wordn = random.randint(1, c)
infile1 = open("Word.txt", "r")
for x in range(wordn):
word = infile1.readline()
word = word.replace("\n", "")
infile1.close()
word = word.upper()
elif (begin == "INPUT"):
wordCheck(word)
guess = ""
guessCheck(guess)
print("Guess: " + guess)
def hangmanGraphics(guesses):
if (guesses == 0):
print ("________ ")
print ("| | ")
print ("| ")
print ("| ")
print ("| ")
print ("| ")
elif (guesses == 1):
print ("_______ ")
print ("| | ")
print ("| O ")
print ("| ")
print ("| ")
print ("| ")
elif (guesses == 2):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| / ")
print ("| ")
print ("| ")
elif (guesses == 3):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /| ")
print ("| ")
print ("| ")
elif (guesses == 4):
print ("________ ")
print ("| | ")
print ("| 0 ")
print ("| /|\ ")
print ("| ")
print ("| ")
elif (guesses == 5):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /|\ ")
print ("| / ")
print ("| ")
elif (guesses == 6):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /|\ ")
print ("| / \ ")
print ("| ")
elif (guesses == 7):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /|\ ")
print ("| / \_ ")
print ("| ")
elif (guesses == 8):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /|\ ")
print ("| _/ \_ ")
print ("| ")
elif (guesses == 9):
print ("________ ")
print ("| | ")
print ("| O ")
print ("| /|\_ ")
print ("| _/ \_ ")
print ("| ")
else:
print ("________ ")
print ("| | ")
print ("| O ")
print ("| _/|\_ ")
print ("| _/ \_ ")
print ("| ")
print ("Game Over")