-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.py
More file actions
92 lines (73 loc) · 3.18 KB
/
Copy pathmenu.py
File metadata and controls
92 lines (73 loc) · 3.18 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import pygame
def carregar_imagem_segura(nome_arquivo, largura, altura):
try:
img = pygame.image.load(nome_arquivo).convert()
return pygame.transform.scale(img, (largura, altura))
except pygame.error:
return None
def mostrar_tela_inicial(tela, largura_janela, altura_janela):
rodando = True
relogio = pygame.time.Clock()
fase_intro = 0
# Imagens do início do jogo
img_casa = carregar_imagem_segura("sprites/plano1.jpg", largura_janela, altura_janela)
img_janela = carregar_imagem_segura("sprites/plano2.jpg", largura_janela, altura_janela)
img_queda = carregar_imagem_segura("sprites/plano3.jpg", largura_janela, altura_janela)
while rodando:
tela.fill((0, 0, 0))
for evento in pygame.event.get():
if evento.type == pygame.QUIT:
return "sair"
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_SPACE:
if fase_intro == 0:
fase_intro = 1
elif fase_intro == 1:
fase_intro = 2
elif fase_intro == 2:
rodando = False
# Fotos em tela cheia
if fase_intro == 0 and img_casa:
tela.blit(img_casa, (0, 0))
elif fase_intro == 1 and img_janela:
tela.blit(img_janela, (0, 0))
elif fase_intro == 2 and img_queda:
tela.blit(img_queda, (0, 0))
pygame.display.flip()
relogio.tick(60)
return "jogar"
# --- Game Over ---
def mostrar_game_over(tela, largura_janela, altura_janela):
tela.fill((0, 0, 0))
fonte = pygame.font.SysFont("Arial", 40, bold=True)
txt1 = fonte.render("GAME OVER", True, (231, 76, 60))
txt2 = pygame.font.SysFont("Arial", 20).render("Pressione ESPAÇO para reiniciar", True, (255, 255, 255))
tela.blit(txt1, txt1.get_rect(center=(largura_janela // 2, altura_janela // 2 - 30)))
tela.blit(txt2, txt2.get_rect(center=(largura_janela // 2, altura_janela // 2 + 30)))
pygame.display.flip()
while True:
for evento in pygame.event.get():
if evento.type == pygame.QUIT:
return "sair"
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_SPACE:
return "jogar"
if evento.key == pygame.K_q:
return "sair"
# --- Vitória ---
def mostrar_final_vitoria(tela, largura_janela, altura_janela):
# Imagem do fim do jogo
img_sofa = carregar_imagem_segura("sprites/plano4.jpg", largura_janela, altura_janela)
while True:
tela.fill((255, 255, 255))
if img_sofa:
tela.blit(img_sofa, (0, 0))
pygame.display.flip()
for evento in pygame.event.get():
if evento.type == pygame.QUIT or (evento.type == pygame.KEYDOWN and evento.key == pygame.K_q):
return "sair"
# Para não quebrar o HUD fixo da main.py se ela chamar:
def desenhar_texto(tela, texto, tamanho, x, y, cor=(255, 255, 255)):
fonte = pygame.font.SysFont("Arial", tamanho, bold=True)
superficie = fonte.render(texto, True, cor)
tela.blit(superficie, superficie.get_rect(center=(x, y)))