-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (44 loc) · 1.44 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pygame
from sys import exit
from game_logic import Game
from score import Score
# Inicializar Pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("Snake Game")
clock = pygame.time.Clock()
font = pygame.font.Font(None, 36)
# Criar uma instância do jogo
snake_game = Game(screen)
score = Score()
def show_start_screen():
start_screen = True
while start_screen:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
start_screen = False
screen.fill((0, 0, 0))
start_text = font.render("Pressione ESPAÇO para começar", True, (255, 255, 255))
instructions_text = font.render("Use as setas do teclado para mover a cobra", True, (255, 255, 255))
screen.blit(start_text, (200, 200))
screen.blit(instructions_text, (150, 300))
pygame.display.flip()
while True:
show_start_screen()
while True:
# Process events
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
# Atualizar estado do jogo
snake_game.update()
# Desenhar tudo
screen.fill((0, 0, 0))
snake_game.draw(screen)
# Atualizar a exibição
pygame.display.flip()
# Limitar a taxa de quadros
clock.tick(10)