-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.py
More file actions
512 lines (458 loc) · 22.5 KB
/
Copy pathmenu.py
File metadata and controls
512 lines (458 loc) · 22.5 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# ============================================
# menu.py - Menu principal y pantallas finales
# ============================================
import math
import pygame
from config import (
SCREEN_WIDTH,
SCREEN_HEIGHT,
MENU_BG_TOP,
MENU_BG_BOT,
MENU_SELECTED,
MENU_NORMAL,
MENU_TITLE,
MENU_SUBTITLE,
WOOD_COLOR,
WOOD_DARK,
WOOD_LIGHT,
WHITE,
LIGHT_GRAY,
ENDING_PERFECT,
ENDING_PARTIAL,
ENDING_FAILURE,
ENDING_TIMEOUT,
WALL_COLOR,
WALL_TOP_COLOR,
FLOOR_PATIO,
)
class MainMenu:
OPTIONS = ["Juego Nuevo", "Controles", "Opciones", "Creditos", "Salir"]
def __init__(self, sound_manager):
self.sound_manager = sound_manager
self.selected = 0
self.sub_screen = None
self.font_title = pygame.font.SysFont("Arial", 62, bold=True)
self.font_subtitle = pygame.font.SysFont("Arial", 24, bold=True)
self.font_panel_title = pygame.font.SysFont("Arial", 24, bold=True)
self.font_option = pygame.font.SysFont("Arial", 32, bold=True)
self.font_text = pygame.font.SysFont("Arial", 17)
self.font_small = pygame.font.SysFont("Arial", 14)
self.font_key = pygame.font.SysFont("Consolas", 16, bold=True)
self.time = 0
self.click_flash = 0.0
self.panel_rect = pygame.Rect(54, 160, 360, 492)
self.option_h = 62
self.option_gap = 12
self.option_left = self.panel_rect.left + 28
self.option_w = self.panel_rect.width - 56
self.option_top = self.panel_rect.top + 88
self.stars = []
for i in range(48):
sx = (i * 137) % SCREEN_WIDTH
sy = 28 + (i * 71) % (SCREEN_HEIGHT // 2 - 20)
bright = 145 + (i * 23) % 100
self.stars.append((sx, sy, bright))
def _get_option_rect(self, idx):
y = self.option_top + idx * (self.option_h + self.option_gap)
return pygame.Rect(self.option_left, y, self.option_w, self.option_h)
def update(self, events, dt):
self.time += dt
self.click_flash = max(0.0, self.click_flash - dt * 2.2)
if self.sub_screen:
for event in events:
if event.type == pygame.KEYDOWN and event.key in (pygame.K_ESCAPE, pygame.K_RETURN, pygame.K_e):
self.sound_manager.play("select")
self.sub_screen = None
return None
if event.type == pygame.MOUSEBUTTONDOWN:
mouse = pygame.mouse.get_pos()
back_btn = pygame.Rect(SCREEN_WIDTH // 2 - 80, SCREEN_HEIGHT - 80, 160, 40)
if back_btn.collidepoint(mouse):
self.sound_manager.play("select")
self.sub_screen = None
return None
if self.sub_screen == "options":
sound_btn = pygame.Rect(SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT // 2 - 20, 200, 45)
if sound_btn.collidepoint(mouse):
self.sound_manager.toggle()
self.sound_manager.play("select")
return None
for event in events:
if event.type == pygame.KEYDOWN:
if event.key in (pygame.K_UP, pygame.K_w):
self.selected = (self.selected - 1) % len(self.OPTIONS)
self.sound_manager.play("select")
elif event.key in (pygame.K_DOWN, pygame.K_s):
self.selected = (self.selected + 1) % len(self.OPTIONS)
self.sound_manager.play("select")
elif event.key in (pygame.K_RETURN, pygame.K_e):
self.click_flash = 0.15
return self._select_option()
if event.type == pygame.MOUSEMOTION:
mouse = pygame.mouse.get_pos()
for i in range(len(self.OPTIONS)):
if self._get_option_rect(i).collidepoint(mouse):
if self.selected != i:
self.selected = i
break
if event.type == pygame.MOUSEBUTTONDOWN:
mouse = pygame.mouse.get_pos()
for i in range(len(self.OPTIONS)):
if self._get_option_rect(i).collidepoint(mouse):
self.selected = i
self.click_flash = 0.18
self.sound_manager.play("select")
return self._select_option()
return None
def _select_option(self):
option = self.OPTIONS[self.selected]
if option == "Juego Nuevo":
return "new_game"
if option == "Controles":
self.sub_screen = "controls"
elif option == "Opciones":
self.sub_screen = "options"
elif option == "Creditos":
self.sub_screen = "credits"
elif option == "Salir":
return "quit"
return None
def draw(self, surface):
pygame.mouse.set_visible(True)
if self.sub_screen:
self._draw_sub_screen(surface)
else:
self._draw_main_menu(surface)
def _draw_main_menu(self, surface):
# Cielo de dia
top = (142, 196, 232)
mid = (173, 217, 242)
bottom = (196, 227, 236)
for y in range(SCREEN_HEIGHT):
t = y / SCREEN_HEIGHT
if t < 0.55:
u = t / 0.55
r = int(top[0] * (1 - u) + mid[0] * u)
g = int(top[1] * (1 - u) + mid[1] * u)
b = int(top[2] * (1 - u) + mid[2] * u)
else:
u = (t - 0.55) / 0.45
r = int(mid[0] * (1 - u) + bottom[0] * u)
g = int(mid[1] * (1 - u) + bottom[1] * u)
b = int(mid[2] * (1 - u) + bottom[2] * u)
pygame.draw.line(surface, (r, g, b), (0, y), (SCREEN_WIDTH, y))
# Sol arriba a la izquierda (encima del menu)
sun_x, sun_y = 120, 88
pygame.draw.circle(surface, (246, 218, 104), (sun_x, sun_y), 38)
for ang in range(0, 360, 30):
rad = math.radians(ang)
x1 = int(sun_x + math.cos(rad) * 46)
y1 = int(sun_y + math.sin(rad) * 46)
x2 = int(sun_x + math.cos(rad) * 59)
y2 = int(sun_y + math.sin(rad) * 59)
pygame.draw.line(surface, (244, 210, 92), (x1, y1), (x2, y2), 2)
# Suelo/patio en capas
pygame.draw.rect(surface, (80, 140, 76), (0, SCREEN_HEIGHT - 268, SCREEN_WIDTH, 268))
pygame.draw.rect(surface, (64, 126, 60), (0, SCREEN_HEIGHT - 192, SCREEN_WIDTH, 192))
# Detalle de pasto
for i in range(140):
gx = (i * 31 + 11) % SCREEN_WIDTH
gy = SCREEN_HEIGHT - 188 + (i * 17) % 162
shade = 72 + (i * 9) % 24
pygame.draw.line(surface, (30, shade, 33), (gx, gy), (gx + 3, gy - 6), 1)
# Casa principal mas a la derecha y cerca del pasto
house_w = 410
house_h = 250
house_x = SCREEN_WIDTH - house_w - 74
house_y = SCREEN_HEIGHT - house_h - 150
# Cerca detras de la casa (incluyendo lado izquierdo del menu)
fence_y = house_y + 126
for x in range(0, SCREEN_WIDTH, 38):
pygame.draw.rect(surface, (115, 103, 83), (x, fence_y, 10, 54))
pygame.draw.rect(surface, (92, 80, 64), (x, fence_y, 10, 54), 1)
pygame.draw.rect(surface, (118, 106, 86), (0, fence_y + 11, SCREEN_WIDTH, 7))
pygame.draw.rect(surface, (105, 92, 74), (0, fence_y + 35, SCREEN_WIDTH, 7))
# Cuerpo de la casa (pintado despues para que la valla no la atraviese)
pygame.draw.rect(surface, WALL_COLOR, (house_x, house_y, house_w, house_h))
pygame.draw.rect(surface, WALL_TOP_COLOR, (house_x, house_y, house_w, house_h), 3)
roof = [
(house_x - 24, house_y + 14),
(house_x + house_w // 2, house_y - 108),
(house_x + house_w + 24, house_y + 14),
]
pygame.draw.polygon(surface, (132, 71, 38), roof)
pygame.draw.polygon(surface, (92, 46, 23), roof, 3)
# Ventanas
for wx in [house_x + 48, house_x + 273]:
wy = house_y + 68
pygame.draw.rect(surface, (120, 142, 165), (wx, wy, 78, 68))
pygame.draw.rect(surface, (194, 184, 152), (wx, wy, 78, 68), 3)
pygame.draw.line(surface, (194, 184, 152), (wx + 39, wy), (wx + 39, wy + 68), 2)
pygame.draw.line(surface, (194, 184, 152), (wx, wy + 34), (wx + 78, wy + 34), 2)
# Puerta
door = pygame.Rect(house_x + 170, house_y + 150, 70, 100)
pygame.draw.rect(surface, (88, 54, 30), door)
pygame.draw.rect(surface, (63, 37, 18), door, 2)
pygame.draw.circle(surface, (204, 180, 72), (door.right - 11, door.centery + 6), 4)
# Camino desde el centro abajo hacia la puerta
path_points = [
(SCREEN_WIDTH // 2 - 88, SCREEN_HEIGHT),
(SCREEN_WIDTH // 2 + 88, SCREEN_HEIGHT),
(door.centerx + 60, door.bottom + 4),
(door.centerx - 60, door.bottom + 4),
]
pygame.draw.polygon(surface, (193, 180, 154), path_points)
pygame.draw.polygon(surface, (170, 156, 132), path_points, 2)
# Titulo movido un poco a la izquierda
title = self.font_title.render("30 Segundos", True, (255, 143, 123))
sub = self.font_subtitle.render("Antes de la Tragedia", True, (42, 64, 86))
sub_shadow = self.font_subtitle.render("Antes de la Tragedia", True, (10, 12, 16))
title_shadow = self.font_title.render("30 Segundos", True, (24, 27, 34))
tx = SCREEN_WIDTH // 2 + 40
surface.blit(title_shadow, title_shadow.get_rect(center=(tx + 3, 68)))
surface.blit(title, title.get_rect(center=(tx, 66)))
surface.blit(sub_shadow, sub_shadow.get_rect(center=(tx + 2, 110)))
surface.blit(sub, sub.get_rect(center=(tx, 108)))
# Ingeniero 2D caricaturesco de espaldas, ubicado sobre el camino
px = SCREEN_WIDTH // 2 + 150
py = SCREEN_HEIGHT - 140
pygame.draw.ellipse(surface, (22, 46, 22), (px - 18, py + 28, 40, 12))
# piernas
pygame.draw.rect(surface, (42, 67, 104), (px - 7, py - 2, 8, 28))
pygame.draw.rect(surface, (36, 58, 93), (px + 2, py - 6, 8, 32))
pygame.draw.rect(surface, (24, 24, 28), (px - 9, py + 24, 13, 4))
pygame.draw.rect(surface, (24, 24, 28), (px + 1, py + 24, 13, 4))
# torso de espaldas
pygame.draw.rect(surface, (58, 89, 126), (px - 10, py - 34, 24, 30), border_radius=2)
pygame.draw.rect(surface, (52, 78, 110), (px - 8, py - 32, 20, 8), border_radius=2)
# brazos caidos
pygame.draw.rect(surface, (50, 76, 108), (px - 15, py - 30, 6, 22))
pygame.draw.rect(surface, (50, 76, 108), (px + 13, py - 30, 6, 22))
# cabeza / casco vistos desde atras
pygame.draw.circle(surface, (240, 196, 152), (px + 2, py - 44), 10)
pygame.draw.rect(surface, (238, 154, 80), (px - 8, py - 58, 20, 8), border_radius=3)
pygame.draw.rect(surface, (214, 131, 66), (px - 11, py - 51, 24, 4), border_radius=2)
# mochila o portapapeles en la espalda
pygame.draw.rect(surface, (122, 84, 46), (px - 5, py - 28, 14, 18), border_radius=2)
pygame.draw.rect(surface, (86, 57, 30), (px - 5, py - 28, 14, 18), 2, border_radius=2)
# Panel izquierdo estilo cartel
panel_shadow = self.panel_rect.move(8, 8)
pygame.draw.rect(surface, (20, 20, 30, 130), panel_shadow, border_radius=14)
pygame.draw.rect(surface, (64, 54, 38), self.panel_rect, border_radius=14)
pygame.draw.rect(surface, (131, 107, 76), self.panel_rect, 4, border_radius=14)
header = pygame.Rect(self.panel_rect.left, self.panel_rect.top, self.panel_rect.width, 64)
pygame.draw.rect(surface, (84, 69, 48), header, border_top_left_radius=14, border_top_right_radius=14)
header_text = self.font_panel_title.render("MENU PRINCIPAL", True, (242, 224, 176))
surface.blit(header_text, header_text.get_rect(center=header.center))
# Textura leve del panel
for y in range(self.panel_rect.top + 74, self.panel_rect.bottom - 10, 11):
pygame.draw.line(
surface,
(102, 84, 60),
(self.panel_rect.left + 10, y),
(self.panel_rect.right - 10, y),
1,
)
# Opciones
for i, option in enumerate(self.OPTIONS):
rect = self._get_option_rect(i)
hovered = rect.collidepoint(pygame.mouse.get_pos())
selected = i == self.selected
base = (95, 79, 55)
hover = (112, 91, 64)
active = (134, 104, 66)
color = active if selected else (hover if hovered else base)
pygame.draw.rect(surface, color, rect, border_radius=10)
pygame.draw.rect(surface, (62, 50, 33), rect, 2, border_radius=10)
if selected:
pulse = 72 + int(48 * (0.5 + 0.5 * math.sin(self.time * 5.2)))
glow = pygame.Surface((rect.width + 16, rect.height + 16), pygame.SRCALPHA)
pygame.draw.rect(glow, (255, 217, 114, pulse), glow.get_rect(), border_radius=14)
surface.blit(glow, (rect.x - 8, rect.y - 8))
if selected and self.click_flash > 0:
c_alpha = int(170 * (self.click_flash / 0.18))
click_glow = pygame.Surface((rect.width, rect.height), pygame.SRCALPHA)
click_glow.fill((255, 255, 255, c_alpha))
surface.blit(click_glow, rect.topleft)
txt_col = (255, 236, 188) if selected else (240, 229, 209)
txt = self.font_option.render(option, True, txt_col)
surface.blit(txt, txt.get_rect(center=rect.center))
def _draw_sub_screen(self, surface):
for y in range(SCREEN_HEIGHT):
t = y / SCREEN_HEIGHT
r = int(30 * (1 - t) + 45 * t)
g = int(30 * (1 - t) + 35 * t)
b = int(50 * (1 - t) + 55 * t)
pygame.draw.line(surface, (r, g, b), (0, y), (SCREEN_WIDTH, y))
if self.sub_screen == "controls":
self._draw_controls(surface)
elif self.sub_screen == "options":
self._draw_options(surface)
elif self.sub_screen == "credits":
self._draw_credits(surface)
back_btn = pygame.Rect(SCREEN_WIDTH // 2 - 80, SCREEN_HEIGHT - 80, 160, 40)
mouse = pygame.mouse.get_pos()
hover = back_btn.collidepoint(mouse)
b_color = (80, 80, 100) if hover else (60, 60, 80)
pygame.draw.rect(surface, b_color, back_btn, border_radius=8)
pygame.draw.rect(surface, WHITE, back_btn, 2, border_radius=8)
b_text = self.font_option.render("Volver", True, WHITE)
surface.blit(b_text, b_text.get_rect(center=back_btn.center))
def _draw_controls(self, surface):
title = self.font_title.render("Controles", True, WHITE)
surface.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, 50)))
controls = [
("Movimiento", "W A S D o Flechas"),
("Recoger libro / Entrar bunker", "Tecla E"),
("Entregar respuesta", "Enter o clic en Entregar"),
("Interaccion en bunker", "Clic del mouse"),
("Pausa", "Boton de pausa"),
]
y = 130
for label, keys in controls:
label_text = self.font_text.render(label + ":", True, (180, 200, 220))
surface.blit(label_text, (120, y))
key_text = self.font_key.render(keys, True, (255, 215, 0))
surface.blit(key_text, (140, y + 28))
pygame.draw.line(surface, (60, 60, 80), (120, y + 55), (SCREEN_WIDTH - 120, y + 55), 1)
y += 70
def _draw_options(self, surface):
title = self.font_title.render("Opciones", True, WHITE)
surface.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, 50)))
sound_on = self.sound_manager.is_enabled()
status = "ACTIVADO" if sound_on else "DESACTIVADO"
status_color = (100, 255, 100) if sound_on else (255, 100, 100)
label = self.font_text.render("Sonido:", True, (180, 200, 220))
surface.blit(label, label.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 60)))
sound_btn = pygame.Rect(SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT // 2 - 20, 200, 45)
mouse = pygame.mouse.get_pos()
hover = sound_btn.collidepoint(mouse)
btn_color = (80, 80, 100) if hover else (60, 60, 80)
pygame.draw.rect(surface, btn_color, sound_btn, border_radius=8)
pygame.draw.rect(surface, status_color, sound_btn, 2, border_radius=8)
s_text = self.font_option.render(status, True, status_color)
surface.blit(s_text, s_text.get_rect(center=sound_btn.center))
hint = self.font_small.render("Clic para cambiar", True, LIGHT_GRAY)
surface.blit(hint, hint.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 45)))
def _draw_credits(self, surface):
title = self.font_title.render("Creditos", True, WHITE)
surface.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, 50)))
credits = [
"",
"30 Segundos Antes de la Tragedia",
"",
"Creado por:",
"Exal Antonio Herrera Marin || 2222919",
"",
"Daniel Humberto Flores Martinez || 2177905",
"",
"Sergio Emiliano Guerrero Fabela || 1867077",
"",
"Fernando Aleman Fabela || 2065560",
"",
"Erick Alejandro Bernal Pérez || 1957371",
"",
"Institución:",
"Facultad de Ingeniería Mecanica y Electrica",
"",
"Materia:",
"Metodos Numericos",
"",
"Desarrollado con:",
"Python + Pygame-CE",
]
y = 130
for line in credits:
if line == "":
y += 10
continue
if line.startswith("Creado") or line.startswith("Institucion") or line.startswith("Materia") or line.startswith("Desarrollado"):
color = (180, 200, 220)
font = self.font_text
else:
color = MENU_SELECTED
font = self.font_option
text = font.render(line, True, color)
surface.blit(text, text.get_rect(center=(SCREEN_WIDTH // 2, y)))
y += 30
class EndScreen:
def __init__(self, sound_manager):
self.sound_manager = sound_manager
self.ending_type = None
self.days_completed = 0
self.font_title = pygame.font.SysFont("Arial", 34, bold=True)
self.font_text = pygame.font.SysFont("Arial", 20)
self.font_small = pygame.font.SysFont("Arial", 16)
self.font_button = pygame.font.SysFont("Arial", 20, bold=True)
self.time = 0
def init(self, ending_type, days_completed=0):
self.ending_type = ending_type
self.days_completed = days_completed
self.time = 0
if ending_type in (ENDING_PERFECT, ENDING_PARTIAL):
self.sound_manager.play("victoria")
else:
self.sound_manager.play("error")
def update(self, events, dt):
self.time += dt
for event in events:
if event.type == pygame.MOUSEBUTTONDOWN:
mouse = pygame.mouse.get_pos()
btn_rect = pygame.Rect(SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT - 100, 200, 45)
if btn_rect.collidepoint(mouse):
self.sound_manager.play("select")
return "menu"
if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
self.sound_manager.play("select")
return "menu"
return None
def draw(self, surface):
if self.ending_type == ENDING_PERFECT:
bg_top, bg_bot, accent = (20, 60, 20), (10, 40, 30), (100, 255, 100)
elif self.ending_type == ENDING_PARTIAL:
bg_top, bg_bot, accent = (20, 40, 60), (15, 30, 50), (100, 200, 255)
elif self.ending_type == ENDING_FAILURE:
bg_top, bg_bot, accent = (60, 20, 20), (40, 10, 15), (255, 100, 100)
else:
bg_top, bg_bot, accent = (50, 30, 10), (35, 20, 10), (255, 150, 50)
for y in range(SCREEN_HEIGHT):
t = y / SCREEN_HEIGHT
r = int(bg_top[0] * (1 - t) + bg_bot[0] * t)
g = int(bg_top[1] * (1 - t) + bg_bot[1] * t)
b = int(bg_top[2] * (1 - t) + bg_bot[2] * t)
pygame.draw.line(surface, (r, g, b), (0, y), (SCREEN_WIDTH, y))
if self.ending_type == ENDING_PERFECT:
line1, line2, line3 = "Felicidades, lo has conseguido", "Eres todo un genio", "Dias resueltos: 6/6"
elif self.ending_type == ENDING_PARTIAL:
line1, line2, line3 = "Enhorabuena", "Has conseguido que te rescaten", f"Dias resueltos: {self.days_completed}/6"
elif self.ending_type == ENDING_FAILURE:
line1, line2, line3 = "Estas perdido", "No has podido ser rescatado", f"Dias completados: {self.days_completed}/6"
else:
line1, line2, line3 = "Tiempo agotado", "No has podido entrar al bunker", ""
y = 190
t1 = self.font_title.render(line1, True, accent)
surface.blit(t1, t1.get_rect(center=(SCREEN_WIDTH // 2, y)))
y += 50
t2 = self.font_text.render(line2, True, WHITE)
surface.blit(t2, t2.get_rect(center=(SCREEN_WIDTH // 2, y)))
y += 40
if line3:
t3 = self.font_text.render(line3, True, LIGHT_GRAY)
surface.blit(t3, t3.get_rect(center=(SCREEN_WIDTH // 2, y)))
y += 40
if self.ending_type == ENDING_FAILURE:
rec = self.font_small.render("Recomendacion: agarra todos los libros que puedas,", True, (200, 200, 150))
rec2 = self.font_small.render("sirven como apoyo visual para resolver los problemas.", True, (200, 200, 150))
surface.blit(rec, rec.get_rect(center=(SCREEN_WIDTH // 2, y + 20)))
surface.blit(rec2, rec2.get_rect(center=(SCREEN_WIDTH // 2, y + 44)))
btn_rect = pygame.Rect(SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT - 100, 200, 45)
mouse = pygame.mouse.get_pos()
hover = btn_rect.collidepoint(mouse)
if hover:
btn_color = (min(255, accent[0] + 30), min(255, accent[1] + 30), min(255, accent[2] + 30))
else:
btn_color = accent
pygame.draw.rect(surface, btn_color, btn_rect, border_radius=10)
pygame.draw.rect(surface, WHITE, btn_rect, 2, border_radius=10)
b_text = self.font_button.render("Volver al menu", True, WHITE)
surface.blit(b_text, b_text.get_rect(center=btn_rect.center))