CLI Python Hangman
This is a project I did back in 2019 as a part of a homework assignment. But I got bored with the regular specifications so I made another version - this version - in which I put all the fun stuff.
Initially when the program first runs it has to create 2 files inside its folder, which may be the reason for any unexpected program exits when trying to load the game for the very-first time. Multiple re-runs may be required.
The program also requires internet acess (as is also stated in the game itself) in order to load images to the screen. Which is perhaps not worth the extra requirement, but this was intended as a learning experience - so everything goes!
Anyway, here's my code:
2021.1 Hangman - Windows x86, Python 2.0-3.8 (py)
from subprocess import call
import webbrowser
from time import sleep
import os
from os import system, name
import random
import io
import base64
import ctypes
import msvcrt
import subprocess
import winsound
import math
import wave
import struct
from ctypes import wintypes
from pathlib import Path
try:
# Python2
import Tkinter as tk
from urllib2 import urlopen
except ImportError:
# Python3
import tkinter as tk
from urllib.request import urlopen
guessedletters = []
rightguesses = []
progress = []
tries = 6
ifComplete = False
word = ''
preword = ''
progress = []
words = []
my_file = Path("hangmanadditionals.wav")
audio = []
sample_rate = 44100.0
chunk = 1024
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
user32 = ctypes.WinDLL('user32', use_last_error=True)
SW_MAXIMIZE = 3
kernel32.GetConsoleWindow.restype = wintypes.HWND
kernel32.GetLargestConsoleWindowSize.restype = wintypes._COORD
kernel32.GetLargestConsoleWindowSize.argtypes = (wintypes.HANDLE,)
user32.ShowWindow.argtypes = (wintypes.HWND, ctypes.c_int)
def append_silence(duration_milliseconds):
"""
Adding silence is easy - we add zeros to the end of our array
"""
num_samples = duration_milliseconds * (sample_rate / 1000.0)
for x in range(int(num_samples)):
audio.append(0.0)
return #silence def
def append_sinewave(freq, duration_milliseconds, volume):
num_samples = duration_milliseconds * (sample_rate / 1000.0)
for x in range(int(num_samples)):
audio.append(volume * math.sin(2 * math.pi * freq * ( x / sample_rate )))
return #note adding def for writing the music
def writemusic():
append_sinewave(294,900,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_silence(400)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_silence(400)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(330,100,1)
append_silence(400)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_silence(400)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_sinewave(330,100,1)
append_silence(400)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_silence(400)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(233,100,1)
append_silence(300)
append_sinewave(262,100,1)
append_silence(300)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_silence(400)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_silence(400)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(294,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_silence(400)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(330,100,1)
append_silence(400)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_silence(400)
append_sinewave(349,100,1)
append_sinewave(349,100,1)
append_sinewave(330,100,1)
append_silence(400)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(330,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_silence(400)
append_sinewave(311,100,1)
append_sinewave(311,100,1)
append_sinewave(233,100,1)
append_silence(400)
append_sinewave(262,100,1)
append_silence(400)
append_sinewave(196,2500,1)
append_sinewave(294,500,1)
append_sinewave(262,333,1)
append_sinewave(233,100,1)
append_sinewave(233,500,1)#A3
append_sinewave(262,333,1)#d4
append_sinewave(294,100,1)
append_sinewave(294,500,1)
append_sinewave(196,1833,1)
append_sinewave(294,500,1)
append_sinewave(262,333,1)
append_sinewave(233,100,1)
append_sinewave(233,500,1)
append_sinewave(220,500,1)
append_sinewave(196,2500,1)
def save_wav(file_name):
wav_file=wave.open(file_name,"w")
nchannels = 1
sampwidth = 2
nframes = len(audio)
comptype = "NONE"
compname = "not compressed"
wav_file.setparams((nchannels, sampwidth, sample_rate, nframes, comptype, compname))
for sample in audio:
wav_file.writeframes(struct.pack('h', int( sample * 32767.0 )))
wav_file.close()
return #save music as .wav file
def maximize_console(lines=None): # This function maximizes the console size to it's maximum regardless to the screen size
fd = os.open('CONOUT$', os.O_RDWR)
try:
hCon = msvcrt.get_osfhandle(fd)
max_size = kernel32.GetLargestConsoleWindowSize(hCon)
if max_size.X == 0 and max_size.Y == 0:
raise ctypes.WinError(ctypes.get_last_error())
finally:
os.close(fd)
cols = max_size.X
hWnd = kernel32.GetConsoleWindow()
if cols and hWnd:
if lines is None:
lines = max_size.Y
else:
lines = max(min(lines, 9999), max_size.Y)
subprocess.check_call('mode.com con cols={} lines={}'.format(cols, lines))
user32.ShowWindow(hWnd, SW_MAXIMIZE)
def defineword(path):
global word , progress , preword , words
if not(path):
open("deafult_List.txt","w+").write("self abundant flower healthy mark spy glorious fold order bewildered mere befitting few classy lush peaceful cats hot inject wish punch cooperative grotesque envious cows plane organic educate house remove report ring womanly murder dolls save ocean divergent shrug dark keen offend wet good guiltless afford guard picture bikes secretary trashy dust market frogs power fancy enjoy houses form wrap ready slimy swanky useful scatter harbor slim grandmother destruction cream jail damage smart move death ablaze things pushy call ossified collar energetic coil delicious wing cars rings mask ignore late cub beef versed travel exclusive enchanted twig ill-fated tasteless gaping mindless spade obsolete file psychedelic rejoice cough saw face maddening thought insurance instrument carpenter painful fantastic separate point meal ill-informed unable test quaint nutty zephyr strip fearful bag muscle old-fashioned upbeat judicious tiresome rate wriggle fear strange common examine stop moor airport judge disillusioned baseball appreciate end bell expensive rabbits pen press cent caring mixed excellent irritating prevent succinct cherries airplane spill nauseating pinch loving rare lucky cart adamant weigh sore slap balance carry zinc queue warn spooky able ripe minor join leather punishment quarter flower change sable wholesale holistic yam dashing seashore deer shivering memorise groovy conscious hurt plough nervous automatic motion abusive scintillating internal kettle bath telephone produce pan mend flimsy true irate man rightful pest sign pump walk guarded chew various current blade aboriginal silk feigned sun milky obedient scrape bored cheer wise skate nimble teeny smash clear improve short large fowl imagine offer nose alluring laugh locket delirious tart count fumbling wistful remain brawny pies pleasant soup plastic watch unwieldy neighborly balance sweater drawer smiling decorate geese quilt prefer lace eager talk bury woman forgetful measly church stereotyped can substance thin transport venomous nifty adjustment channel hour tick orange long-term class settle rhyme quicksand ambiguous planes distance placid idea prose gratis four icky allow jump arrest hope gaze cook disagreeable steady unhealthy skirt manage uttermost crazy somber jam touch fresh rebel suggest theory loutish branch crib identify whip voice license extra-small frame van diligent reflective name knowledge makeshift crash chance lazy roll curve lumber suck purple unused parcel sparkling downtown actor park frightened sneeze depressed trade sink easy sky muddle deeply noiseless liquid vengeful bizarre left want nippy economic gifted support greasy copper invite worry tank fence new wrist damp eggnog hate brass literate answer caption squeamish argumentprotective sedate table truthful obeisant rail grandiose second anxious young range first busy majestic encourage little elbow attack defective word metal itchy fascinated amusement actually dry pollution violent wire cycle important animate plate wealth mountainous base hum fabulous macabre adventurous painstaking heady female bone straw sugar supreme mean stupid alert picayune object string roasted evanescent boat tacky daughter work neat stomach earn naughty activity humor sidewalk rat miss cuddly debt abashed precious list profit morning grey fill accept wink blink boy milk deep collect vague sock zip graceful flaky frequent brother trains quirky therapeutic lowly form force probable spiky hungry arm robin squeal sister careful teeth pipe")
lines = open("deafult_List.txt","r").readlines()
else:
lines = open(path).readlines()
line = lines[0]
words = line.split()
preword = random.choice(words)
while not preword.isalpha():
preword = random.choice(words)
word = preword.title()
progress = ['_']*len(word)
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
clear()
input('''\033[38;5;9mWARNING: INTERNET CONNECTION IS REQUIRED TO PLAY THIS GAME''')
def loadingAnimation():
ntoslp = 0.01
print('''
╔══════════════════════════════╗
║ ║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████████████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████████████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████████████████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████████████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████████████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████████████████ \033[0m║
╚══════════════════════════════╝
loading
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████████████████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████████████████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████████████████████ \033[0m║
╚══════════════════════════════╝
loading.
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████████████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m███████████████████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m████████████████████████████ \033[0m║
╚══════════════════════════════╝
loading..
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m█████████████████████████████ \033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
print('''
╔══════════════════════════════╗
║\033[38;5;10m██████████████████████████████\033[0m║
╚══════════════════════════════╝
loading...
''')
sleep(ntoslp)
clear()
if not(my_file.is_file()):
writemusic()
save_wav('hangmanadditionals.wav')
def regu(): # I went for a "flickering text" opening (from clean to "corrupted") to add interest
winsound.PlaySound("hangmanadditionals.wav", winsound.SND_LOOP + winsound.SND_ASYNC)
print(("""\033[0m
██╗ ██╗ █████╗ ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ███╗ ██╗
██║ ██║ ██╔══██╗ ████╗ ██║ ██╔════╝ ████╗ ████║ ██╔══██╗ ████╗ ██║
███████║ ███████║ ██╔██╗ ██║ ██║ ███╗ ██╔████╔██║ ███████║ ██╔██╗ ██║
██╔══██║ ██╔══██║ ██║╚██╗██║ ██║ ██║ ██║╚██╔╝██║ ██╔══██║ ██║╚██╗██║
██║ ██║ ██║ ██║ ██║ ╚████║ ╚██████╔╝ ██║ ╚═╝ ██║ ██║ ██║ ██║ ╚████║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝
""") + " \033[0myou have " + str(tries) + ' tries')
def corrupt():
print (("""\033[38;5;52m
██░ ██ ▄▄▄ ███▄ █ ▄████ ███▄ ▄███▓ ▄▄▄ ███▄ █
▓██░ ██▒ ▒████▄ ██ ▀█ █ ██▒ ▀█▒ ▓██▒▀█▀ ██▒ ▒████▄ ██ ▀█ █
▒██▀▀██░ ▒██ ▀█▄ ▓██ ▀█ ██▒ ▒██░▄▄▄░ ▓██ ▓██░ ▒██ ▀█▄ ▓██ ▀█ ██▒\033[38;5;88m
░▓█ ░██ ░██▄▄▄▄██ ▓██▒ ▐▌██▒ ░▓█ ██▓ ▒██ ▒██ ░██▄▄▄▄██ ▓██▒ ▐▌██▒
░▓█▒░██▓ ▓█ ▓██▒ ▒██░ ▓██░ ░▒▓███▀▒ ▒██▒ ░██▒ ▓█ ▓██▒ ▒██░ ▓██░\033[38;5;124m
▒ ░░▒░▒ ▒▒ ▓▒█░ ░ ▒░ ▒ ▒ ░▒ ▒ ░ ▒░ ░ ░ ▒▒ ▓▒█░ ░ ▒░ ▒ ▒ \033[38;5;58m
▒ ░▒░ ░ ▒ ▒▒ ░ ░ ░░ ░ ▒░ ░ ░ ░ ░ ░ ▒ ▒▒ ░ ░ ░░ ░ ▒░\033[38;5;22m
░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
""")+ " \033[38;5;22myou have " + str(tries) + ' tries')
def start(): # I am using the Ascii art once more and not the regu() function because of the little text aside ("The computer game!")
clear()
print(("""\033[0m
██╗ ██╗ █████╗ ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ███╗ ██╗
██║ ██║ ██╔══██╗ ████╗ ██║ ██╔════╝ ████╗ ████║ ██╔══██╗ ████╗ ██║
███████║ ███████║ ██╔██╗ ██║ ██║ ███╗ ██╔████╔██║ ███████║ ██╔██╗ ██║
██╔══██║ ██╔══██║ ██║╚██╗██║ ██║ ██║ ██║╚██╔╝██║ ██╔══██║ ██║╚██╗██║
██║ ██║ ██║ ██║ ██║ ╚████║ ╚██████╔╝ ██║ ╚═╝ ██║ ██║ ██║ ██║ ╚████║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ The computer game!
""") + " you have " + str(tries) + ' tries')
print('\033[38;5;220m Press Enter To Start!')
input('')
clear()
corrupt()
sleep(0.01)
clear()
regu()
sleep(0.01)
clear()
corrupt()
sleep(0.02)
clear()
regu()
sleep(0.01)
clear()
corrupt()
print ("\033[38;5;58Y You Have No Idea What You're Getting Into...\033[0m")
sleep(2)
root = tk.Tk() #the following code opens a funny tkinter comics regarding the small chances of winning
root.title("You Don't Stand A Chance")
w = 520
h = 700
x = 700
y = 0
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
image_url = "https://sites.google.com/site/oooo999zzaaa9entergames/xbvjdkfgjf/hi.gif"
image_byt = urlopen("https://sites.google.com/site/oooo999zzaaa9entergames/xbvjdkfgjf/hi.gif").read()
image_b64 = base64.encodebytes(image_byt)
photo = tk.PhotoImage(data=image_b64)
cv = tk.Canvas(bg='white')
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(10, 10, image=photo, anchor='nw')
root.mainloop()
def draw():
if (tries == 6):
clear() # I decided to use a more entertaining kind of graphics than the one pointed out at the campus course several times
print("""
___
(^<^) < "oh hello!"
--< >--
| |
_/ \_
""")
if (tries == 5):
clear()
print("""
___
(o_o) < "I don't wanna die!"
--< >--
| | _________________
_/ \_ | |
""")
if (tries == 4): # The chratecter starts quoting the song "Bohemian rhapsody" by the band "Queen" with some amusing modifications
clear()
print ("""
___
(o_o) < "mamaaa, I just killed a mannn..."
--< >--
| | _________________
_/ \_ | |
""")
if (tries == 3):
clear()
print ("""
.
|
|
|
|
___ |
(o_o) < "life has just began!!" |
--< >-- |
| | _________|________
_/ \_ | |
""")
if (tries == 2):
clear()
print ("""
.______________
|
|
|
|
___ |
(o_o) < "and if this guy (or gal) can't guess the word- |
--< >-- I'm gonna dieeeee" |
| | _________|________
_/ \_ | |
""")
if (tries == 1):
clear()
print("""
.______________.
| |
| |
| |
|
___ |
(o_o) < "please don't do this. can't you just take my wife?" |
--< >-- |
| | _________|________
_/ \_ | |
""")
if (tries == 0):
clear()
print ("""
.______________.
| |
| |
| |
| _^_
| (x_x) < "just so you know: I am very disappointed."
| --< >--
| | |
_________|________ _/ \_
| |
""")
root = tk.Tk() #the following code open a tkinter window which consists of an amusing meme assuring the user that he is bad.
root.title("You Lost")
w = 520
h = 520
x = 80
y = 100
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
image_url = "https://sites.google.com/site/oooo999zzaaa9entergames/xbvjdkfgjf/363yjw.gif"
image_byt = urlopen(image_url).read()
image_b64 = base64.encodebytes(image_byt)
photo = tk.PhotoImage(data=image_b64)
cv = tk.Canvas(bg='white')
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(10, 10, image=photo, anchor='nw')
root.mainloop()
if ifComplete: # This specific state is for a case of victory
clear()
print('''\033[38;5;220m
___
(^<^) < "Yay I get to live!
--< >-- I would have killed you if you were to lose"
| |
_/ \_
\033[0m''')
root = tk.Tk() #the following code open a tkinter window which consists of an amusing meme for congratulating the player
root.title("You Won!")
w = 680
h = 520
x = 80
y = 100
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
image_url = "https://sites.google.com/site/oooo999zzaaa9entergames/xbvjdkfgjf/364iwf.gif"
image_byt = urlopen(image_url).read()
image_b64 = base64.encodebytes(image_byt)
photo = tk.PhotoImage(data=image_b64)
cv = tk.Canvas(bg='white')
cv.pack(side='top', fill='both', expand='yes')
cv.create_image(10, 10, image=photo, anchor='nw')
root.mainloop()
def isitval(guess):
global tries
if ((not guess) or (not(guess.isalpha()))) or (len(guess) > 1) or guess.lower() in guessedletters: print('\nX\n\n' + ' => '.join(sorted(guessedletters)))
else:
guessedletters.append(guess.lower())
if (guess in preword):
while (preword.count(guess) > rightguesses.count(guess)):
for i in range (len(preword)):
if preword[i] == guess.lower(): rightguesses.append(guess.lower())
elif tries > 0:
tries -= 1
print (' D: ')
def reveal():
for i in range (len(preword)):
if (preword[i] in rightguesses):
progress[i] = word[i]
print (' '.join(progress), '\n tries left: ' , tries)
def IfComplete():
global ifComplete
for letter in range (len(preword)):
if preword[letter] in rightguesses:
if (letter == len(word) - 1):
print ('you won!!')
sleep(2)
ifComplete = True
draw()
else:
break
def GAME():
defineword(input('Enter list path here \033[38;5;9mOr just press enter for the deafult word list\033[0m:\n'))
global ifComplete , tries , rightguesses , guessedletters
rightguesses = []
guessedletters = []
progress = []
ifComplete = False
tries = 6
draw()
print((len(word)) * "_ ", '\n tries left: ' , tries)
while (not (ifComplete)) and tries > 0:
isitval(guess = input('please guess a letter: '))
sleep(0.3)
draw()
reveal()
IfComplete()
if tries <= 0:
print ('you lost, the word was: ' + word)
sleep(5)
clear()
replay()
def replay():
abc = 0
ToReplay = False
while abc == 0:
if (not (input('''\033[38;5;128;48;5;16m
██████╗ ██████╗ ███████╗███████╗███████╗ ███████╗███╗ ██╗████████╗███████╗██████╗ ████████╗ ██████╗
██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔══██╗ ╚══██╔══╝██╔═══██╗
██████╔╝██████╔╝█████╗ ███████╗███████╗ █████╗ ██╔██╗ ██║ ██║ █████╗ ██████╔╝ ██║ ██║ ██║
██╔═══╝ ██╔══██╗██╔══╝ ╚════██║╚════██║ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗ ██║ ██║ ██║
██║ ██║ ██║███████╗███████║███████║ ███████╗██║ ╚████║ ██║ ███████╗██║ ██║ ██║ ╚██████╔╝
╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝
██████╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗ █████╗ ██╗███╗ ██╗
██╔══██╗██║ ██╔══██╗╚██╗ ██╔╝ ██╔══██╗██╔════╝ ██╔══██╗██║████╗ ██║
██████╔╝██║ ███████║ ╚████╔╝ ███████║██║ ███╗███████║██║██╔██╗ ██║
██╔═══╝ ██║ ██╔══██║ ╚██╔╝ ██╔══██║██║ ██║██╔══██║██║██║╚██╗██║
██║ ███████╗██║ ██║ ██║ ██║ ██║╚██████╔╝██║ ██║██║██║ ╚████║
╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝\033[0m
'''))):
abc = 1
GAME()
clear()
maximize_console()
loadingAnimation()
start()
GAME()
The default word-list used is:
self abundant flower healthy mark spy glorious fold order bewildered mere befitting few classy lush peaceful cats hot inject wish punch cooperative grotesque envious cows plane organic educate house remove report ring womanly murder dolls save ocean divergent shrug dark keen offend wet good guiltless afford guard picture bikes secretary trashy dust market frogs power fancy enjoy houses form wrap ready slimy swanky useful scatter harbor slim grandmother destruction cream jail damage smart move death ablaze things pushy call ossified collar energetic coil delicious wing cars rings mask ignore late cub beef versed travel exclusive enchanted twig ill-fated tasteless gaping mindless spade obsolete file psychedelic rejoice cough saw face maddening thought insurance instrument carpenter painful fantastic separate point meal ill-informed unable test quaint nutty zephyr strip fearful bag muscle old-fashioned upbeat judicious tiresome rate wriggle fear strange common examine stop moor airport judge disillusioned baseball appreciate end bell expensive rabbits pen press cent caring mixed excellent irritating prevent succinct cherries airplane spill nauseating pinch loving rare lucky cart adamant weigh sore slap balance carry zinc queue warn spooky able ripe minor join leather punishment quarter flower change sable wholesale holistic yam dashing seashore deer shivering memorise groovy conscious hurt plough nervous automatic motion abusive scintillating internal kettle bath telephone produce pan mend flimsy true irate man rightful pest sign pump walk guarded chew various current blade aboriginal silk feigned sun milky obedient scrape bored cheer wise skate nimble teeny smash clear improve short large fowl imagine offer nose alluring laugh locket delirious tart count fumbling wistful remain brawny pies pleasant soup plastic watch unwieldy neighborly balance sweater drawer smiling decorate geese quilt prefer lace eager talk bury woman forgetful measly church stereotyped can substance thin transport venomous nifty adjustment channel hour tick orange long-term class settle rhyme quicksand ambiguous planes distance placid idea prose gratis four icky allow jump arrest hope gaze cook disagreeable steady unhealthy skirt manage uttermost crazy somber jam touch fresh rebel suggest theory loutish branch crib identify whip voice license extra-small frame van diligent reflective name knowledge makeshift crash chance lazy roll curve lumber suck purple unused parcel sparkling downtown actor park frightened sneeze depressed trade sink easy sky muddle deeply noiseless liquid vengeful bizarre left want nippy economic gifted support greasy copper invite worry tank fence new wrist damp eggnog hate brass literate answer caption squeamish argumentprotective sedate table truthful obeisant rail grandiose second anxious young range first busy majestic encourage little elbow attack defective word metal itchy fascinated amusement actually dry pollution violent wire cycle important animate plate wealth mountainous base hum fabulous macabre adventurous painstaking heady female bone straw sugar supreme mean stupid alert picayune object string roasted evanescent boat tacky daughter work neat stomach earn naughty activity humor sidewalk rat miss cuddly debt abashed precious list profit morning grey fill accept wink blink boy milk deep collect vague sock zip graceful flaky frequent brother trains quirky therapeutic lowly form force probable spiky hungry arm robin squeal sister careful teeth pipe
Game Audio inspired by the works of Alan Silvestri.