-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCredits.py
More file actions
116 lines (97 loc) · 5.48 KB
/
Copy pathCredits.py
File metadata and controls
116 lines (97 loc) · 5.48 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
import pygame
from pygame.locals import *
from pygame import mixer
class Credits:
#sound
def __init__(self,width,height,screen,ch1,ch2,ch3,ch4,font):
#screen
self.screen = screen
#musica
self.pressed = pygame.mixer.Sound('sounds/button_pressed.wav')
self.pressed_exit = pygame.mixer.Sound('sounds/button_pressed_ogg.ogg')
self.selected = pygame.mixer.Sound('sounds/selected_button.wav')
#widht y height
self.width = width
self.height = height
#canales
self.ch1 = ch1
self.ch2 = ch2
self.ch3 = ch3
self.ch4 = ch4
#variables
self.first_timeB = True # Aún no has pulsado el botón volver al menú
#cargamos las imágenes del menú
self.backgroundPic = pygame.image.load("images/background.png")
self.titlePic = pygame.image.load("images/title.png")
self.buttonPic = pygame.image.load("images/button.png")
self.buttonSelectedPic = pygame.image.load("images/button_selected.png")
self.buttonPressedPic = pygame.image.load("images/button_pressed.png")
self.papiro = pygame.image.load("images/papiro.png")
#fuentes y colores
self.fuente = pygame.font.SysFont(font, 70)
self.fuente2 = pygame.font.SysFont(font,600)
self.color_white = (255,255,255)
self.color_black = (0,0,0)
self.back = self.fuente.render('Volver al menú', True, self.color_white)
self.titleText = self.fuente2.render(' Roleplay Simulator ',True,self.color_white)
self.autor1 = self.fuente.render('Desarrollado por: Teresa Valero Díaz', True, self.color_black)
self.autor2 = self.fuente.render('Tutora: María Julia Flores Gallego', True, self.color_black)
def setScreen(self,screen):
self.screen = screen
#self.width,self.height= (self.screen.get_width(), self.screen.get_height())
def getScreen(self):
return self.screen
def render(self):
#render screen
self.screen.blit(pygame.transform.scale(self.backgroundPic, (self.width,self.height)), (0, 0)) #0,0 es la posición desde donde empieza a dibujar
self.screen.blit(pygame.transform.scale(self.titleText, (self.width/1.0000, self.height/3.8889)), (0, self.height/28.0000)) #1200 180 0 25
self.screen.blit(pygame.transform.scale(self.papiro, (self.width/2.0000, self.height/3.0435)), (self.width/4.4444, self.height/1.7500))
self.screen.blit(pygame.transform.scale(self.autor1, (self.width/3.0000, self.height/17.5000)), (self.width/3.1579, self.height/1.5909))
self.screen.blit(pygame.transform.scale(self.autor2, (self.width/3.0769, self.height/17.5000)), (self.width/3.1579, self.height/1.4286))
self.screen.blit(pygame.transform.scale(self.buttonPic, (self.width/3.8339, self.height/12.2807)), (self.width/2.7907, self.height/1.1667))
self.screen.blit(pygame.transform.scale(self.back, (self.width/6.3158, self.height/17.5000)), (self.width/2.4490, self.height/1.1570))
pygame.display.update()
# size_x, size_y: tamaño del botón en x y en y
# x_start y y_start: posición de la esquina izquierda del botón
# pos_x y pos_y: posición actual del ratón
def checkIfMouseIsInButton(self,size_x,size_y,x_start,y_start,pos_x,pos_y):
if((pos_x >= x_start and pos_x <= size_x+x_start) and (pos_y >= y_start and pos_y <= size_y + y_start)):
return True
else:
return False
def clickedMouse(self):
#click del ratón
#calculo del tamaño del botón y su posición -> Empezar Simulación
x_size = self.width/3.8339
y_size = self.height/12.2807
x_start = self.width/2.7907
y_start = self.height/1.1667
(x,y) = pygame.mouse.get_pos()
#Botón volver al menú
if(self.checkIfMouseIsInButton(x_size,y_size,x_start,y_start,x,y)):
self.screen.blit(pygame.transform.scale(self.buttonPressedPic, (self.width/3.8339, self.height/12.2807)), (self.width/2.7907, self.height/1.1667))
self.screen.blit(pygame.transform.scale(self.back, (self.width/6.3158, self.height/17.5000)), (self.width/2.4490, self.height/1.1570))
self.ch1.play(self.pressed)
pygame.display.update()
return 'menu'
else:
return 'credits'
def movedMouse(self):
x_size = self.width/3.8339
y_size = self.height/12.2807
x_start = self.width/2.7907
y_start = self.height/1.1667
(x,y) = pygame.mouse.get_pos()
#Botón volver al menú
if(self.checkIfMouseIsInButton(x_size,y_size,x_start,y_start,x,y)):
self.screen.blit(pygame.transform.scale(self.buttonSelectedPic, (self.width/3.8339, self.height/12.2807)), (self.width/2.7907, self.height/1.1667))
self.screen.blit(pygame.transform.scale(self.back, (self.width/6.3158, self.height/17.5000)), (self.width/2.4490, self.height/1.1570))
if(self.first_timeB):
self.first_timeB = False
self.ch2.play(self.selected)
pygame.display.update()
else:
self.first_timeB = True
self.screen.blit(pygame.transform.scale(self.buttonPic, (self.width/3.8339, self.height/12.2807)), (self.width/2.7907, self.height/1.1667))
self.screen.blit(pygame.transform.scale(self.back, (self.width/6.3158, self.height/17.5000)), (self.width/2.4490, self.height/1.1570))
pygame.display.update()