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
14 changes: 14 additions & 0 deletions Snake/Snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pygame
from pygame.locals import *

#Pause Variable
pause=False

def text_display(size, caption, posix, posiy):
font = pygame.font.Font('freesansbold.ttf', size)
Expand Down Expand Up @@ -225,6 +227,18 @@ def update(self):
snake_parts.draw(screen)
snake_parts.update()

for event in pygame.event.get():
if event.type==KEYUP:
if event.key==K_p:
pause = True

Comment on lines +230 to +234
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, use a formatter (eg. black) so that the code is in match with the rest.

while pause == True:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need not compare a True value with itself, just : while pause: will do.

for event in pygame.event.get():
if event.type==KEYUP:
if event.key==K_p:
pause = False


if not snake_parts.sprites():
text_display(128, 'Game Over', 600, 300)
else:
Expand Down