def __init__(self, x, y, width, height, nombre, activa, enabled): self.imagen = pygame.image.load( st.current_dir() + "/data/cards/{}".format(nombre)).convert_alpha() self.imagen = pygame.transform.scale(self.imagen, (width, height)) if activa != False: self.imagen_activa = pygame.image.load( st.current_dir() + "/data/cards/{}".format(activa)).convert_alpha() self.imagen_activa = pygame.transform.scale( self.imagen_activa, (width, height)) self.imagen_inactiva = self.imagen self.u1 = pygame.Rect(x, y, width, height) self.long = x self.tall = y self.tall_aux = y self.enabled = enabled self.name = nombre
def render(self, clock, screen, p): if not self.st_done: screen.fill(self.background_color) string = "Saltar el tutorial?" screen.blit(self.fondo.getImg(), (self.fondo.getX(), self.fondo.getY())) question_text = tt.render_text("S", string, self.white) screen.blit(question_text, (290, 200)) while not self.st_done: pygame.display.update() screen.blit(self.skip.getImg(), (self.skip.getX(), self.skip.getY())) screen.blit(self.show_tut.getImg(), (self.show_tut.getX(), self.show_tut.getY())) [ self.get_event(event, pygame.key.get_pressed()) for event in pygame.event.get() ] temp = pygame.image.load( st.current_dir() + "/data/other/game_start3.png").convert_alpha() temp = pygame.transform.scale(temp, (800, 500)) screen.blit(temp, (0, 0)) pygame.time.delay(600) pygame.display.update()
def createBG(self): self.bg_array = [] for i in range(1, 6): temp = pygame.image.load( st.current_dir() + "/data/other/{}.png".format(str(i))).convert_alpha() temp = pygame.transform.scale(temp, (800, 500)) self.bg_array.append(temp)
def render(self, clock, screen, p): screen.fill(self.background_color) count = 0 self.selectDurakMusic() if self.durak > 0: durak_text = tt.render_text( "S", "El Jugador " + str(self.durak) + " es el Rey de los Idiotas!", self.white) else: durak_text = tt.render_text( "M", "No levanto mi sombrero ante un idiota!", self.white) while not self.st_done: fools_hat = pygame.image.load( st.current_dir() + "/data/other/fool.png").convert_alpha() term_text = tt.render_text( "S", ">Presione SPACE para volver al menu...", self.white_to_bg_fade[count % len(self.white_to_bg_fade)]) screen.blit(term_text, (p[0] / 2 - term_text.get_width() // 2, p[1] - term_text.get_height() - 100 // 2)) screen.blit(durak_text, (p[0] / 2 - durak_text.get_width() // 2, p[1] // 2 - durak_text.get_height() // 2)) screen.blit(fools_hat, (p[0] / 2 - fools_hat.get_width() // 2, p[1] - 380 - fools_hat.get_height() // 2)) pygame.display.flip() count += 1 clock.tick(5) [ self.get_event(event, pygame.key.get_pressed()) for event in pygame.event.get() ]
def __init__(self): st.Estados_Juego.__init__(self) jacket_button1 = pygame.image.load( st.current_dir() + "/data/cards/jacket_1.png").convert_alpha() jacket_button2 = pygame.image.load( st.current_dir() + "/data/cards/jacket_2.png").convert_alpha() self.b1 = pygame.Rect(102, 154, 135, 181) self.b2 = pygame.Rect(322, 154, 135, 181) self.b3 = pygame.Rect(552, 154, 135, 181) jacket_button1 = pygame.transform.scale(jacket_button1, (160, 226)) jacket_button2 = pygame.transform.scale(jacket_button2, (160, 226)) self.images = [jacket_button1, jacket_button2] print("Estoy en clase Menu de modeulo menu.py")
def __init__(self): st.Estados_Juego.__init__(self) self.integrante1 = "Anastasiia Fedorova" self.rol_int1 = "201873505-1" self.integrante2 = "Ignacio Jorquera" self.rol_int2 = "201873561-2" self.paralelo = "200" self.sem = "2019-2" self.ramo = "Lenguajes de Programacion" self.next = "MENU" self.logo_utfsm = pygame.image.load( st.current_dir() + "/data/other/utfsm_pixel.png").convert_alpha() self.logo_utfsm = pygame.transform.scale(self.logo_utfsm, (250, 160))
def render(self, clock, screen, p): self.i = 0 self.createBG() curr = self.bg_array[0] while not self.st_done: screen.blit(curr, (0, 0)) question_text = tt.render_text( "S", self.strings[self.i], self.background_color) screen.blit(self.fondo.getImg(), (self.fondo.getX(), self.fondo.getY())) screen.blit(question_text, (self.fondo.getRekt().center[0] - question_text.get_width() // 2, self.fondo.getRekt().center[1] - question_text.get_height() // 2)) self.mostrarFlechas(screen) # Explicación de cantidades if self.i == 4: curr = self.bg_array[1] # Explicación sobre cartas de jugador if self.i == 8: curr = self.bg_array[2] # Explicación sobre los oponentes if self.i == 12: curr = self.bg_array[0] # Explicación sobre el ataque/defensa if self.i == 19: curr = self.bg_array[3] # Explicación sobre UP/DOWN y uso de botones if self.i == 21: curr = self.bg_array[4] # Expliaciones que quedan. if self.i == 32: curr = self.bg_array[0] pygame.display.update() [self.get_event(event, pygame.key.get_pressed()) for event in pygame.event.get()] # Pantalla de "loading..." temp = pygame.image.load( st.current_dir() + "/data/other/game_start3.png").convert_alpha() temp = pygame.transform.scale(temp, (800, 500)) screen.blit(temp, (0, 0)) pygame.display.update()
import pygame from sys_tools import current_dir path = current_dir() + "/data/fonts/font.ttf" pygame.font.init() font_T = pygame.font.Font(path, 15) font_S = pygame.font.Font(path, 20) font_M = pygame.font.Font(path, 60) font_B = pygame.font.Font(path, 80) font_L = pygame.font.Font(path, 100) def render_text(size, text, color): if size == "T": font = font_T.render(text, True, color) elif size == "S": font = font_S.render(text, True, color) elif size == "M": font = font_M.render(text, True, color) elif size == "B": font = font_B.render(text, True, color) elif size == "L": font = font_L.render(text, True, color) return font
def getImgNaipe(self, w, h): imagen = pygame.image.load( st.current_dir() + "/data/cards/{}".format(self.fileNaipe())).convert_alpha() imagen = pygame.transform.scale(imagen, (w, h)) return imagen