slight changes to game loop to not constantly change the led colours at every tick
This commit is contained in:
parent
16c32133cb
commit
5d62d58478
@ -22,9 +22,6 @@ from pygame.locals import *
|
||||
pygame_fps = 30 #frames per second setting
|
||||
pygame_clock = pygame.time.Clock()
|
||||
|
||||
# font colors
|
||||
pygame_font_main_color = pygame_color_black
|
||||
|
||||
# GPIO for Buttons
|
||||
pin_start = 32
|
||||
pin_error = 31
|
||||
@ -80,6 +77,9 @@ pygame_color_yellow = pygame.Color(255, 215, 0)
|
||||
pygame_color_grey = pygame.Color(196, 202, 206)
|
||||
pygame_color_brown = pygame.Color(177, 86, 15)
|
||||
|
||||
# font colors
|
||||
pygame_font_main_color = pygame_color_black
|
||||
|
||||
# initialise gpio
|
||||
GPIO.setmode(GPIO.BOARD)
|
||||
GPIO.setup(pin_start, GPIO.IN)
|
||||
@ -87,10 +87,9 @@ GPIO.setup(pin_error, GPIO.IN)
|
||||
GPIO.setup(pin_shutdown, GPIO.IN)
|
||||
|
||||
# predefinition of led variables, for use in functions
|
||||
led_red = ""
|
||||
led_green = ""
|
||||
led_blue = ""
|
||||
|
||||
led_red = 0
|
||||
led_green = 0
|
||||
led_blue = 0
|
||||
|
||||
############################################
|
||||
########## END OF INITIALISATION ###########
|
||||
@ -360,12 +359,16 @@ game_running = False
|
||||
|
||||
while True:
|
||||
|
||||
clear_screen()
|
||||
handle_events()
|
||||
|
||||
if game_running == False:
|
||||
clear_screen()
|
||||
print("New game starting")
|
||||
change_led_colour(10,140,10)
|
||||
|
||||
if game_just_started == True:
|
||||
print("New game starting")
|
||||
change_led_colour(10,140,10)
|
||||
game_just_started = False
|
||||
|
||||
time_surface = 0
|
||||
errors_surface = 0
|
||||
time_rectangle = 0
|
||||
@ -435,6 +438,7 @@ while True:
|
||||
errors_rectangle.topleft = (640, 560)
|
||||
|
||||
clear_screen()
|
||||
|
||||
screen.blit(errors_surface, errors_rectangle) #errors
|
||||
screen.blit(time_surface, time_rectangle) #time
|
||||
screen.blit(header_surface, header_rectangle) #header
|
||||
@ -460,6 +464,8 @@ while True:
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
# nach dem spiel ist vor dem spiel
|
||||
game_just_started = True
|
||||
clear_screen()
|
||||
|
||||
pygame.display.update()
|
||||
|
Loading…
Reference in New Issue
Block a user