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)
This commit is contained in:
parent
9e2086611c
commit
48df332b32
@ -23,8 +23,8 @@
|
|||||||
# GND (25) (26) -
|
# GND (25) (26) -
|
||||||
# - (27) (28) -
|
# - (27) (28) -
|
||||||
# - (29) (30) GND
|
# - (29) (30) GND
|
||||||
# pin_error (31) (32) pin_start
|
# - (31) (32) pin_start
|
||||||
# - (33) (34) GND
|
# pin_error (33) (34) GND
|
||||||
# - (35) (36) -
|
# - (35) (36) -
|
||||||
# - (37) (38) -
|
# - (37) (38) -
|
||||||
# GND (39) (40) -
|
# GND (39) (40) -
|
||||||
@ -32,7 +32,7 @@
|
|||||||
# default state of pins:
|
# default state of pins:
|
||||||
#
|
#
|
||||||
# 32: pull up
|
# 32: pull up
|
||||||
# 31: pull down
|
# 33: pull up
|
||||||
# 3: pull down
|
# 3: pull down
|
||||||
#
|
#
|
||||||
# make sure leds are on pull-up default pins
|
# make sure leds are on pull-up default pins
|
||||||
@ -67,7 +67,7 @@ pygame_clock = pygame.time.Clock()
|
|||||||
|
|
||||||
# GPIO for Buttons
|
# GPIO for Buttons
|
||||||
pin_start = 32
|
pin_start = 32
|
||||||
pin_error = 31
|
pin_error = 33
|
||||||
pin_shutdown = 3
|
pin_shutdown = 3
|
||||||
|
|
||||||
# GPIO for LED
|
# GPIO for LED
|
||||||
@ -76,7 +76,8 @@ pin_green = 18
|
|||||||
pin_blue = 16
|
pin_blue = 16
|
||||||
|
|
||||||
# other constants
|
# 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 settings
|
||||||
screen_size_x = 1920
|
screen_size_x = 1920
|
||||||
@ -262,7 +263,7 @@ def toggle_fullscreen():
|
|||||||
return screen
|
return screen
|
||||||
|
|
||||||
def clear_screen():
|
def clear_screen():
|
||||||
print("filled screen")
|
#print("filled screen")
|
||||||
screen.fill(pygame_color_white)
|
screen.fill(pygame_color_white)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -459,6 +460,7 @@ while True:
|
|||||||
# causing a stop of the game immediately after start
|
# causing a stop of the game immediately after start
|
||||||
pin_start_inhibit = True
|
pin_start_inhibit = True
|
||||||
pin_start_inhibit_timer_start = pygame.time.get_ticks()
|
pin_start_inhibit_timer_start = pygame.time.get_ticks()
|
||||||
|
|
||||||
errors = 0
|
errors = 0
|
||||||
error_added = False
|
error_added = False
|
||||||
|
|
||||||
@ -466,6 +468,7 @@ while True:
|
|||||||
|
|
||||||
start_time = int(time.time())
|
start_time = int(time.time())
|
||||||
|
|
||||||
|
# change led colour to blue
|
||||||
change_led_colour(10,10,100)
|
change_led_colour(10,10,100)
|
||||||
|
|
||||||
if game_running == True: # game running
|
if game_running == True: # game running
|
||||||
@ -505,8 +508,9 @@ while True:
|
|||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
# if the start input is gone and the start pin isnt inhibited
|
# 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)
|
change_led_colour(100,10,10)
|
||||||
|
|
||||||
print("Game ended because start pin wasnt true")
|
print("Game ended because start pin wasnt true")
|
||||||
@ -522,9 +526,10 @@ while True:
|
|||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(5)
|
||||||
|
|
||||||
# nach dem spiel ist vor dem spiel
|
# nach dem spiel ist vor dem spiel
|
||||||
|
game_running = False
|
||||||
game_just_started = True
|
game_just_started = True
|
||||||
clear_screen()
|
clear_screen()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user