kleine änderungen an der struktur des programms, test

This commit is contained in:
Patrick Tschuchnig 2019-08-27 13:28:18 +02:00
parent 04a38a41c9
commit f86cca398c

View File

@ -55,7 +55,6 @@ def toggle_fullscreen():
pygame.key.set_mods(0) #HACK: work-a-round for a SDL bug??
pygame.mouse.set_cursor( *cursor ) # Duoas 16-04-2007
return screen
def clearScreen():
@ -83,8 +82,8 @@ def exit_application():
sys.exit()
return
#def shutdown_raspberry():
#os.system("sudo shutdown -h now")
def shutdown_raspberry():
os.system("sudo shutdown -h now")
return
@ -112,21 +111,20 @@ while True: # main loop
while GPIO.input(startPin) == False: #wait for the user to press start button
handle_events()
start_time = int(time.time())
errors = 0
errorAdded = False
justStarted = True
#justStarted = True
header_surface = font.render('Spiel startet', True, mainFontColor)
time.sleep(5)
header_surface = font.render('Spiel l' + u'ä' + 'uft!', True, mainFontColor)
start_time = int(time.time())
while True: # game running
handle_events()
if GPIO.input(errorPin) == True:
if errorAdded == False:
errors += 1
@ -146,7 +144,6 @@ while True: # main loop
errors_rectangle = errors_surface.get_rect()
errors_rectangle.topleft = (0, 400)
clearScreen()
screen.blit(errors_surface, errors_rectangle) #errors
screen.blit(time_surface, time_rectangle) #time
@ -154,10 +151,12 @@ while True: # main loop
pygame.display.flip()
if GPIO.input(startPin) == False:
justStarted = False
if GPIO.input(startPin) == True and justStarted == False:
break
#if GPIO.input(startPin) == False:
# justStarted = False
#if GPIO.input(startPin) == True and justStarted == False:
if GPIO.input(startPin) == True:
#break
continue #skip the rest
clearScreen()
header_surface = font.render('Game over!', True, mainFontColor)
@ -168,14 +167,15 @@ while True: # main loop
pygame.display.flip()
while GPIO.input(startPin) == False:
handle_events()
#while GPIO.input(startPin) == False:
# handle_events()
while GPIO.input(startPin) == True:
handle_events()
#while GPIO.input(startPin) == True:
# handle_events()
while GPIO.input(startPin) == False:
handle_events()
#while GPIO.input(startPin) == False:
# handle_events()
clearScreen()
time.sleep(1)
time.sleep(10)
break