Allow pause with ESC
This commit is contained in:
parent
9ba1ceff72
commit
cf534e1f13
1 changed files with 8 additions and 0 deletions
8
main.py
8
main.py
|
@ -60,6 +60,14 @@ def main():
|
||||||
snake.direction = Direction.UP
|
snake.direction = Direction.UP
|
||||||
elif event.key == pglocals.K_RIGHT or event.key == pglocals.K_d:
|
elif event.key == pglocals.K_RIGHT or event.key == pglocals.K_d:
|
||||||
snake.direction = Direction.RIGHT
|
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)
|
dirty_rects = snake.move(screen, apple)
|
||||||
if snake.dead:
|
if snake.dead:
|
||||||
|
|
Loading…
Reference in a new issue