From 0e88ce887d4360245f6fd704d28dd13eeb48a89a Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Thu, 21 Sep 2017 15:59:04 +0200 Subject: [PATCH] Quit when pressing 'q' --- photoboite.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/photoboite.py b/photoboite.py index 0b19834..578b475 100755 --- a/photoboite.py +++ b/photoboite.py @@ -5,7 +5,7 @@ pygame.init() infos = pygame.display.Info() # size = infos.current_w, infos.current_h -size = 1024, 768 +size = 1280, 768 background = 255, 255, 255 screen = pygame.display.set_mode(size) @@ -31,16 +31,16 @@ i = 0 pressed = False while True: for event in pygame.event.get(): - if event.type in (pygame.QUIT, pygame.KEYDOWN): + if event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.unicode == 'q': sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: - if button_up_rect.collidepoint(pygame.mouse.get_pos()): + if button_up_rect.collidepoint(event.pos): pressed = True elif event.type == pygame.MOUSEBUTTONUP: - if button_up_rect.collidepoint(pygame.mouse.get_pos()): + if button_up_rect.collidepoint(event.pos): pressed = False i += 1 - if button2.collidepoint(pygame.mouse.get_pos()): + if button2.collidepoint(event.pos): i -= 1 screen.fill(background)