merged image display functions and functionality from imagetest.py

This commit is contained in:
Patrick Tschuchnig 2019-09-10 13:54:01 +02:00
parent c0ba73e5f8
commit cfab44e3aa

View File

@ -57,6 +57,11 @@ hs3_time = 300
# name length for highscores # name length for highscores
MAX_NAME_LENGTH = 10 MAX_NAME_LENGTH = 10
def get_image_width(filepath):
return ((Image.open(filepath).size)[0])
def get_image_height(filepath):
return ((Image.open(filepath).size)[1])
def signal_handler(sig, frame): def signal_handler(sig, frame):
# signal handler, later called to interpret # signal handler, later called to interpret
@ -289,6 +294,12 @@ screen = pygame.display.set_mode((screenSizeX, screenSizeY), pygame.FULLSCREEN)
#screen = toggle_fullscreen() #screen = toggle_fullscreen()
# define image variables
img_itlablogo = 'img/itlablogo.png'
img_itlablogo_image = pygame.image.load(img_itlablogo)
img_itlablogo_imagex = get_image_width(img_itlablogo)
img_itlablogo_imagey = get_image_height(img_itlablogo)
#initialise led strip #initialise led strip
led_init() led_init()
@ -326,6 +337,8 @@ while True: # main loop
screen.blit(score1_surface, score1_rectangle) screen.blit(score1_surface, score1_rectangle)
screen.blit(score2_surface, score2_rectangle) screen.blit(score2_surface, score2_rectangle)
screen.blit(score3_surface, score3_rectangle) screen.blit(score3_surface, score3_rectangle)
screen.blit(img_itlablogo_image, (screenx-img_itlablogo_imagex-20, screeny-img_itlablogo_imagey-20))
pygame.display.flip() pygame.display.flip()
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
@ -380,7 +393,7 @@ while True: # main loop
if GPIO.input(startPin) != True: if GPIO.input(startPin) != True:
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")
checkHighscores(int_time) checkHighscores(int_time)