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
13 changes: 11 additions & 2 deletions sucury.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ def __init__(self):
# The snake has a head segement,
self.head = pygame.Rect(self.x, self.y, GRID_SIZE, GRID_SIZE)


# and a tail (array of segments).
self.tail = []

# initial increase of speed
self.speed = 0
# The snake is born.
self.alive = True

Expand Down Expand Up @@ -191,6 +194,8 @@ def update(self):
self.xmov = 1 # Right
self.ymov = 0 # Still

# Reset increase of speed
self.speed = 0
# Resurrection
self.alive = True

Expand Down Expand Up @@ -347,10 +352,14 @@ def play():
if snake.head.x == apple.x and snake.head.y == apple.y:
snake.tail.append(pygame.Rect(snake.head.x, snake.head.x, GRID_SIZE, GRID_SIZE))
apple = Apple()


# Increase speed in 1 unit for every score multiple of 5
snake.speed = int(len(snake.tail)/5)


# Update display and move clock.
pygame.display.update()
clock.tick(CLOCK_TICKS)
clock.tick(CLOCK_TICKS+snake.speed)

main_menu()
main_menu()