Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sucury.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def center_prompt(title, subtitle):

# Wait for a keypres or a game quit event.

if title == "Pause": return
while ( event := pygame.event.wait() ):
if event.type == pygame.KEYDOWN:
break
Expand Down Expand Up @@ -246,6 +247,9 @@ def draw_grid():
pygame.quit()
sys.exit()
elif event.key == pygame.K_p: # S : pause game
# if game_on:
# center_prompt("Pause", "Press P to return")

game_on = not game_on

## Update the game
Expand All @@ -266,6 +270,9 @@ def draw_grid():
# Draw head
pygame.draw.rect(arena, HEAD_COLOR, snake.head)

if not game_on:
center_prompt("Pause", "Press P to return")

# Show score (snake length = head + tail)
score = BIG_FONT.render(f"{len(snake.tail)}", True, SCORE_COLOR)
arena.blit(score, score_rect)
Expand Down