Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from several developers (GitHub usernames):

* Lucas Almeida (lalmeida32)
* Gustavo Sampaio (GusSampaio)







13 changes: 13 additions & 0 deletions sucury.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pygame
import datetime
import random
import sys

Expand All @@ -43,6 +44,7 @@
GRID_COLOR = "#3c3c3b" # Color of the grid lines.
SCORE_COLOR = "#ffffff" # Color of the scoreboard.
MESSAGE_COLOR = "#808080" # Color of the game-over message.
TIMER_COLOR = "#ffffff" # Color of the timer.

WINDOW_TITLE = "KhobraPy" # Window title.

Expand All @@ -56,6 +58,8 @@

clock = pygame.time.Clock()

time_start = datetime.datetime.now()

arena = pygame.display.set_mode((WIDTH, HEIGHT))

BIG_FONT = pygame.font.Font("assets/font/Ramasuri.ttf", int(WIDTH/8))
Expand Down Expand Up @@ -141,6 +145,10 @@ def update(self):
pygame.draw.rect(arena, DEAD_HEAD_COLOR, snake.head)
center_prompt("Game Over", "Press to restart")

#Reset clock
global time_start
time_start = datetime.datetime.now()

# Respan the head
self.x, self.y = GRID_SIZE, GRID_SIZE
self.head = pygame.Rect(self.x, self.y, GRID_SIZE, GRID_SIZE)
Expand Down Expand Up @@ -275,6 +283,11 @@ def draw_grid():
snake.tail.append(pygame.Rect(snake.head.x, snake.head.x, GRID_SIZE, GRID_SIZE))
apple = Apple()

# Show timer (clock)
time_delta = datetime.datetime.now()
time_delta = time_delta - time_start
time_render = SMALL_FONT.render(str(time_delta).split(".")[0], True, TIMER_COLOR)
arena.blit(time_render, (0, 0))

# Update display and move clock.
pygame.display.update()
Expand Down