Quit when pressing 'q'

master
Guillaume Dott 2017-09-21 15:59:04 +02:00
parent bb02cafc6b
commit 0e88ce887d
1 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,7 @@ pygame.init()
infos = pygame.display.Info() infos = pygame.display.Info()
# size = infos.current_w, infos.current_h # size = infos.current_w, infos.current_h
size = 1024, 768 size = 1280, 768
background = 255, 255, 255 background = 255, 255, 255
screen = pygame.display.set_mode(size) screen = pygame.display.set_mode(size)
@ -31,16 +31,16 @@ i = 0
pressed = False pressed = False
while True: while True:
for event in pygame.event.get(): 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() sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN: elif event.type == pygame.MOUSEBUTTONDOWN:
if button_up_rect.collidepoint(pygame.mouse.get_pos()): if button_up_rect.collidepoint(event.pos):
pressed = True pressed = True
elif event.type == pygame.MOUSEBUTTONUP: elif event.type == pygame.MOUSEBUTTONUP:
if button_up_rect.collidepoint(pygame.mouse.get_pos()): if button_up_rect.collidepoint(event.pos):
pressed = False pressed = False
i += 1 i += 1
if button2.collidepoint(pygame.mouse.get_pos()): if button2.collidepoint(event.pos):
i -= 1 i -= 1
screen.fill(background) screen.fill(background)