From 48df332b32615ad317d9c6790a9dd8ecb4ba9859 Mon Sep 17 00:00:00 2001 From: Patrick Tschuchnig Date: Wed, 11 Sep 2019 10:57:16 +0200 Subject: [PATCH] changed timings, changed a problem with the game restarting, changed logic for game start to be for a closing button, changed pin for errors to be 33 (pull up) --- gametest_rev1.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gametest_rev1.py b/gametest_rev1.py index 6a13d1a..d72a0c2 100644 --- a/gametest_rev1.py +++ b/gametest_rev1.py @@ -23,8 +23,8 @@ # GND (25) (26) - # - (27) (28) - # - (29) (30) GND -# pin_error (31) (32) pin_start -# - (33) (34) GND +# - (31) (32) pin_start +# pin_error (33) (34) GND # - (35) (36) - # - (37) (38) - # GND (39) (40) - @@ -32,7 +32,7 @@ # default state of pins: # # 32: pull up -# 31: pull down +# 33: pull up # 3: pull down # # make sure leds are on pull-up default pins @@ -67,7 +67,7 @@ pygame_clock = pygame.time.Clock() # GPIO for Buttons pin_start = 32 -pin_error = 31 +pin_error = 33 pin_shutdown = 3 # GPIO for LED @@ -76,7 +76,8 @@ pin_green = 18 pin_blue = 16 # other constants -time_per_error = 5 # every time the wire is touched, some time is added as penalty. +# every time the wire is touched, some time is added as penalty. +time_per_error = 5 # screen settings screen_size_x = 1920 @@ -262,7 +263,7 @@ def toggle_fullscreen(): return screen def clear_screen(): - print("filled screen") + #print("filled screen") screen.fill(pygame_color_white) return @@ -459,6 +460,7 @@ while True: # causing a stop of the game immediately after start pin_start_inhibit = True pin_start_inhibit_timer_start = pygame.time.get_ticks() + errors = 0 error_added = False @@ -466,6 +468,7 @@ while True: start_time = int(time.time()) + # change led colour to blue change_led_colour(10,10,100) if game_running == True: # game running @@ -505,8 +508,9 @@ while True: pygame.display.flip() # if the start input is gone and the start pin isnt inhibited - if GPIO.input(pin_start) != True and pin_start_inhibit == False: + if GPIO.input(pin_start) == True and pin_start_inhibit == False: + # change led colour to red change_led_colour(100,10,10) print("Game ended because start pin wasnt true") @@ -522,9 +526,10 @@ while True: pygame.display.flip() - time.sleep(10) + time.sleep(5) # nach dem spiel ist vor dem spiel + game_running = False game_just_started = True clear_screen()