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