Allow pause with ESC

This commit is contained in:
Gabriel Augendre 2018-04-30 20:38:24 +02:00
parent 9ba1ceff72
commit cf534e1f13
No known key found for this signature in database
GPG Key ID: F360212F958357D4
1 changed files with 8 additions and 0 deletions

View File

@ -60,6 +60,14 @@ def main():
snake.direction = Direction.UP
elif event.key == pglocals.K_RIGHT or event.key == pglocals.K_d:
snake.direction = Direction.RIGHT
elif event.key == pglocals.K_ESCAPE:
pause = True
while pause:
clock.tick(5)
for event in pygame.event.get():
if event.type == pglocals.KEYDOWN and event.key == pglocals.K_ESCAPE:
pause = False
break
dirty_rects = snake.move(screen, apple)
if snake.dead: