So I have been trying to put together a really really simple example to get the ball rolling, but seem to be running into a lot of errors. When I comment out the 'while' statement in the functionWelcome it works in terms of displaying the text but will not accept the key event. And when I use the sleep event in the other two functions it will wait the correct amount of time but the screen blanks out. Are there any obvious things that I might be missing?
from visual import *
import time
def function1():
Bob = sphere(pos=vector(-10,-10,0), radius = 1, color = color.red)
Bill = sphere(pos=vector(10,10,0), radius = 1.5, color = color.blue)
Bob.visible = True
Bill.visible = True
time.sleep(10)
Bill.visible = False
Bob.visible = False
functionWelcome()
def function2():
Steve = sphere(pos=vector(10,-10,0), radius = 0.5, color = color.cyan)
Morry = sphere(pos=vector(-10,10,0), radius = 1.7, color = color.yellow)
time.sleep(10)
Steve.visible = False
Morry.visible = False
functionWelcome()
def functionWelcome():
Hello = text(text = "Press h or g to start", align = "center", depth = 0.3, color=color.green)
while true:
if scene.kb.keys:
key = scene.kb.getkey()
if key == "h":
Hello.visible = False
function1()
elif hey == "g":
Hello.visible = False
function2()
functionWelcome()