-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (58 loc) · 2.43 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import pygame
import cv2
from menu.menu import Menu
from utilerias.configuraciones import *
from os.path import join
class VideoInicio:
def __init__(self, screen):
self.screen = screen
def mostrarVideoInicio(self):
pygame.time.wait(0)
self.empezarVideoInicio()
def empezarVideoInicio(self):
pygame.display.set_caption("Inicio - OxyFender")
rutaVideo = join("assets", "videos", "Inicio.mp4")
rutaAudio = join("assets", "videos", "intro.mp3")
cap = cv2.VideoCapture(rutaVideo)
if not cap.isOpened():
return
# Cargar y reproducir el audio
pygame.mixer.music.load(rutaAudio)
pygame.mixer.music.play()
clock = pygame.time.Clock()
activo = True
while activo:
ret, frame = cap.read()
if not ret:
break
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = cv2.resize(frame, (self.screen.get_width(), self.screen.get_height()))
frame = pygame.surfarray.make_surface(frame.swapaxes(0, 1))
for event in pygame.event.get():
if event.type == pygame.QUIT:
activo = False
elif event.type == pygame.MOUSEBUTTONDOWN:
activo = False
elif event.type == pygame.KEYDOWN:
activo = False
self.screen.blit(frame, (0, 0))
# Mostrar mensaje en la parte superior izquierda
font = pygame.font.SysFont(None, 36)
text = font.render("Presione cualquier tecla para continuar", True, (255, 255, 255))
self.screen.blit(text, (10, 10))
pygame.display.update()
clock.tick(30)
cap.release()
pygame.mixer.music.stop()
def main():
pygame.init() # Inicializar pygame
pygame.mixer.init() # Inicializar el mezclador de audio
screen = pygame.display.set_mode((WIDTH, HEIGHT)) # Establecer tamaño de pantalla
pygame.display.set_caption(TITLE_GAME) # Establecer el titulo del juego
pygame.display.set_icon(pygame.image.load(ICON_GAME)) # Establecer el icono del juego
videoInicio = VideoInicio(screen)
videoInicio.mostrarVideoInicio() # Mostrar el video de inicio.
menuInicial = Menu(screen)
menuInicial.mostrarMenuInicial() # Mostrar el menú del juego.
if __name__ == "__main__": # Iniciar el juego si el nombre del archivo es main
main()