Hey all, so I’m trying to make a Hangman game in Processing.py and have written code for both how I want it to look, as well as separate code to run the game. The problem is combining the two in Processing. Is there a way to make a Hangman game with Processing.py? Or am I just wasting my time? Thanks in advance to all that help.
Code for Hangman game (non-processing)
import time
import random
name = input("What is your name? ")
print ("Hello, " + name, "Time to play hangman!")
print ('')
time.sleep(2)
print ("Start guessing...")
bank = ["ironman", "hulk", "captain america", "black widow", "thor", "hawkeye"]
r = (random.randint(0,5))
word = bank[r]
guesses = ''
turns = 10
while turns > 0:
failed = 0
for char in word:
if char in guesses:
print (char, )
else:
print ("_", )
failed += 1
if failed == 0:
print ("You won")
break
print
guess = input("guess a character:")
guesses += guess
if guess not in word:
turns -= 1
print ("Wrong")
print ("You have", + turns, 'more guesses' )
if turns == 0:
print ("You Lose")
Code for Hangman visuals (Processing)
def setup():
size(250,350)
background(102,204,255)
fill(17,214,11)
rect(0,201,250,350)
def draw():
strokeWeight(2)
line(100,100,100,200)
line(100,100,150,100)
line(150,100,150,125)
line(75,200,125,200)
line(85,200,100,175)
line(115,200,100,175)