-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontrols.py
78 lines (55 loc) · 2.66 KB
/
controls.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
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
import pygame
import sys
from button import Button
from Localization_manager import localization
class ControlsScreen:
def __init__(self, state_manager):
# Datos de pantalla
self.state_manager = state_manager
self.selected_level = None
self.screen = pygame.display.set_mode((1280, 720)) # Creamos la ventana con sus medidas
self.clock = pygame.time.Clock() # Reloj para controlar los FPS
# Carga de recursos
self.background = pygame.image.load("assets/sprites/TUTORIAL.png")
font_game = pygame.font.Font("assets/fonts/GAME.TTF", 27)
self.back_image = pygame.image.load("assets/sprites/BOTONSIGUIENTE.png")
#Textos
self.howtoplay_text = font_game.render(localization.get_text("how_to_play"), True, (0, 0, 0)) # Negro
self.back_image = pygame.transform.scale(self.back_image, (110, 110))
# Escalar los recursos y efecto espejo
self.back_image = pygame.transform.flip(self.back_image, True, False)
# Crear botones
self.back_button = Button(self.back_image, (170, 630), "", self.get_font(20), "Black", "Green")
#Escalar
# Carga de texto
self.font = self.get_font(1)
def get_font(self, size):
return pygame.font.Font("assets/fonts/GAME.TTF", size)
def update_texts(self):
# Actualizar el texto del título según el idioma
self.howtoplay_text = self.get_font(1).render(localization.get_text("how_to_play"), True, (0, 0, 0))
def update(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
#if event.type == pygame.MOUSEBUTTONDOWN:
#if self.back_button.checkForInput(pygame.mouse.get_pos()):
#self.state_manager.set_state("main_menu")
def show_controls_screen(self, duration=3000):
start_time = pygame.time.get_ticks()
while pygame.time.get_ticks() - start_time < duration:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
self.draw(self.screen)
pygame.display.flip()
self.clock.tick(60)
def draw(self, screen):
self.screen.blit(self.background, (0, 0))
# Dibujar botón de regreso
#self.back_button.update(screen)
self.screen.blit(self.howtoplay_text, self.howtoplay_text.get_rect(center=(660, 30)))
# Actualizar la pantalla
pygame.display.flip()