diff --git a/AUTHORS b/AUTHORS index 82a4b34..8e56861 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,9 +12,10 @@ from several developers (GitHub usernames): * Lucas Almeida (lalmeida32) + * Gustavo Sampaio (GusSampaio) - \ No newline at end of file + diff --git a/sucury.py b/sucury.py index 74a7d24..a078672 100755 --- a/sucury.py +++ b/sucury.py @@ -24,6 +24,7 @@ # along with this program. If not, see . import pygame +import datetime import random import sys @@ -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. @@ -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)) @@ -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) @@ -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()