Skip to content

Commit

Permalink
Merge pull request #291 from BaruBenoni/treasure
Browse files Browse the repository at this point in the history
Treasure hunt
  • Loading branch information
Techiral authored Jul 12, 2024
2 parents 8c4fe9b + 1290793 commit 1720c7f
Show file tree
Hide file tree
Showing 5 changed files with 2,244 additions and 97 deletions.
22 changes: 21 additions & 1 deletion H/hangman_game/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import random
import hangman_art

!{sys.executable} -m pip install pyfiglet
import pyfiglet as pyfiglet

def text_to_ascii(text, color):
"""
This function turns text into ASCII of a selected colour.
"""
color_code = {'blue': '\033[34m',
'yellow': '\033[33m',
'green': '\033[32m',
'red': '\033[31m',
'purple': '\033[35m',
'cyan': '\033[36m'
}
text = pyfiglet.figlet_format(text)
return color_code[color] + str(text) + '\033[0m'

from word_list import words
choosen_word = random.choice(words)
word_length = len(choosen_word)
Expand All @@ -9,7 +27,8 @@
display = []
for x in range(word_length):
display += "_"
print("Welcome to hangman game")
print(text_to_ascii('Welcome to hangman game','green'))
#print("Welcome to hangman game")
print(f"total life = {life}")
print(hangman_art.logo)
print("word length = " + ' '.join(display))
Expand Down Expand Up @@ -42,4 +61,5 @@
if "_" not in display:
print("You win :) ")
game_end = True


Loading

0 comments on commit 1720c7f

Please sign in to comment.