def load_sprites(self): ''' Carga las señales.''' seniales = G.get_palabras_FGR_T0201() posiciones = G.get_Posicion_Palabras_FGR_T0201() w, h = (0, 0) for palabra in seniales: boton = Sprite_Palabras(self.main, palabra) boton.set_colores(colorbas=JAMG.get_blanco(), colorbor=JAMG.get_blanco(), colorcara=JAMG.get_blanco()) boton.set_text(color=JAMG.get_negro()) boton.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio=25) boton.set_tamanios(tamanio=(0, 0), grosorbor=1, detalle=1, espesor=1) ancho, alto = boton.get_tamanio() if ancho > w: w = ancho if alto > h: h = alto random.seed() posicion = random.choice(posiciones) boton.set_posicion(punto=posicion) posiciones.remove(posicion) self.add(boton) for boton in self.sprites(): boton.set_tamanios(tamanio=(w, h), grosorbor=1, detalle=1, espesor=1) # el sprite para seleccionar las señales self.main.controles.get_recuadro_select((w, h))
def get_labels_carteles(self, texto, centro): ''' Etiquetas sobre los carteles.''' palabras = texto.split(" ") renglon1 = "%s %s" % (palabras[0], palabras[1]) label = JAMLabel(renglon1) label.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() label.set_font_from_file(fuente, tamanio=30) x, y = centro w, h = label.get_tamanio() label.set_posicion(punto=(x - w / 2, y - h)) self.add(label) if len(palabras) > 2: renglon2 = "" ww, hh = label.get_tamanio() for palabra in palabras[2:]: renglon2 += palabra + " " label = JAMLabel(renglon2) label.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() label.set_font_from_file(fuente, tamanio=30) w, h = label.get_tamanio() label.set_posicion(punto=(x - w / 2, y + hh - h)) self.add(label) else: label.set_posicion(punto=(x - w / 2, y))
def __init__(self, main, nombre): JAMButton.__init__(self, ".................", None) self.main = main self.nombre = nombre self.set_colores(colorbas=JAMG.get_negro(), colorbor=JAMG.get_blanco(), colorcara=JAMG.get_negro()) self.set_text(color=JAMG.get_blanco()) self.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio=25) self.set_tamanios(tamanio=(0, 0), grosorbor=1, detalle=1, espesor=1) self.connect(callback=self.main.deja_en)
def __init__(self, main): pygame.sprite.OrderedUpdates.__init__(self) self.main = main self.imagenes = G.get_Presentacion() self.siguiente = None self.anterior = None salir = None self.imagen_actual = None self.estado = True fuente, tamanio = JAMG.get_Font_fawn() w, h = G.RESOLUCION self.siguiente = JAMButton("Siguiente", None) self.siguiente.set_text(color=JAMG.get_blanco()) self.siguiente.set_font_from_file(fuente, tamanio=40) self.siguiente.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) self.siguiente.set_tamanios(tamanio=(150, 0), grosorbor=1, detalle=1, espesor=1) ww, hh = self.siguiente.get_tamanio() self.siguiente.set_posicion(punto=(w - ww - 20, h - hh - 20)) self.siguiente.connect(callback=self.next, sonido_select=None) self.add(self.siguiente) self.anterior = JAMButton("Anterior", None) self.anterior.set_text(color=JAMG.get_blanco()) self.anterior.set_font_from_file(fuente, tamanio=40) self.anterior.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) self.anterior.set_tamanios(tamanio=(150, 0), grosorbor=1, detalle=1, espesor=1) ww, hh = self.anterior.get_tamanio() self.anterior.set_posicion(punto=(20, h - hh - 20)) self.anterior.connect(callback=self.previous, sonido_select=None) self.add(self.anterior) salir = JAMButton("Salir", None) salir.set_text(color=JAMG.get_blanco()) salir.set_font_from_file(fuente, tamanio=40) salir.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) salir.set_tamanios(tamanio=(150, 0), grosorbor=1, detalle=1, espesor=1) ww, hh = salir.get_tamanio() salir.set_posicion(punto=(w / 2 - ww / 2, 20)) salir.connect(callback=self.volver, sonido_select=None) self.add(salir) self.imagen_actual = self.imagenes[0] self.main.fondo = self.imagen_actual
def __init__(self, main): pygame.sprite.OrderedUpdates.__init__(self) self.main = main imagen = G.get_Flecha() salir = JAMButton("",None) salir.set_imagen(origen = imagen, tamanio=(100,55)) salir.set_colores(colorbas =JAMG.get_negro(), colorcara=JAMG.get_negro()) salir.set_tamanios(tamanio =(0,0), grosorbor=1, detalle=1, espesor=1) salir.set_posicion(punto = (10,10)) #salir.connect (callback = self.main.run_dialog_intro) salir.connect (callback = self.main.salir, sonido_select = None) self.add(salir) jugar = JAMButton("Jugar",None) jugar.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() jugar.set_font_from_file(fuente, tamanio= 50) jugar.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) jugar.set_tamanios(tamanio=(200,0), grosorbor=1, detalle=1, espesor=1) w,h = G.RESOLUCION ww,hh = jugar.get_tamanio() jugar.set_posicion(punto= (w-ww-10,h-hh-10)) jugar.connect (callback= self.run_Instruc) self.add(jugar)
def __init__(self, texto): pygame.sprite.Sprite.__init__(self) string_to_render = "" fuente = self.get_Font() string_to_render = unicode( texto.decode("utf-8") ) self.image = fuente.render(string_to_render, 1, JAMG.get_blanco()) self.rect = self.image.get_rect()
def __init__(self, main, texto, valor): pygame.sprite.Sprite.__init__(self) self.main = main self.valor = valor self.select = False textos = texto.split("\n") sprites = [] for texto in textos: sprites.append(Sprite_Texto_Afirmacion(texto)) imagenes = [] w, h = (345, 0) for sprite in sprites: imagen = sprite.image imagenes.append(imagen) if w < sprite.rect.w: w = sprite.rect.w h += sprite.rect.h self.final_unselect = JAMG.get_Rectangulo(JAMG.get_blanco(), (w, h)) self.final_select = JAMG.get_Rectangulo(JAMG.get_amarillo1(), (w, h)) self.image = self.final_unselect self.rect = self.image.get_rect() x, y, w, h = self.rect for img in imagenes: w1, h2 = img.get_size() self.final_unselect.blit(img, (w / 2 - w1 / 2, y)) self.final_select.blit(img, (w / 2 - w1 / 2, y)) y += h2
def __init__(self, main, texto, valor): JAMButton.__init__(self, texto, None) self.valor = valor fuente, tamanio = JAMG.get_Font_fawn() self.set_font_from_file(fuente, tamanio=30) self.set_text(color=JAMG.get_blanco()) self.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) self.set_tamanios(tamanio=(0, 0), grosorbor=1, detalle=1, espesor=1)
def get_sprite_frase(self): labels= [] for frase in self.frase.split("\n"): label= JAMLabel(frase) label.set_text(color= JAMG.get_blanco()) label.set_contenedor(colorbas= JAMG.get_negro(), grosor=1, colorbor=JAMG.get_negro()) label.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio= 50) labels.append(label) return labels
def get_labels_carteles(self, texto, centro): ''' Etiquetas sobre los carteles. ''' label = JAMLabel(texto) label.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() label.set_font_from_file(fuente, tamanio=tamanio) x, y = centro w, h = label.get_tamanio() label.set_posicion(punto=(x - w / 2, y - h / 2)) self.add(label)
def load_sprites(self): palabras = [ "PEDALES", "INFLADOR", "CUADRO", "LUCES", "FRENOS", "ASIENTO", "PLATO" ] x, y = self.main.seniales.get_posicion() w, h = self.main.seniales.get_tamanio() x += w + 5 for pal in palabras: label = JAMLabel(pal) label.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio=50) label.set_text(color=JAMG.get_blanco()) label.set_posicion(punto=(x, y)) y += label.get_tamanio()[1] + 5 self.add(label)
def get_labels(self, afirmacion): fuente, tamanio = JAMG.get_Font_fawn() tamanio = 50 labels = [] textos = afirmacion.split("\n") for t in textos: label = JAMLabel(t) label.set_text(color=JAMG.get_blanco()) label.set_font_from_file(fuente, tamanio=tamanio) labels.append(label) x, y, w, h = self.sprite_imagen.rect labels.reverse() for label in labels: w1, h1 = label.get_tamanio() y -= h1 + 10 label.set_posicion((G.RESOLUCION[0] / 2 - w1 / 2, y)) return labels
def get_sprite_frase(self): label = JAMLabel(self.frase) label.set_text(color=JAMG.get_blanco()) label.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio=50) return label
def __init__(self, texto): JAMLabel.__init__(self, texto) self.set_text(color=JAMG.get_blanco()) self.set_font_from_file(JAMG.get_Font_fawn()[0], tamanio=35)
def load_sprites(self): imagen = self.main.usuario['personaje'] self.user = JAMButton(self.main.usuario['nombre'], None) self.user.set_imagen(origen=imagen, tamanio=(60, 60)) self.user.set_colores(colorbas=(0, 153, 255, 255), colorbor=(0, 153, 255, 255), colorcara=(0, 153, 255, 255)) self.user.set_tamanios(tamanio=(80, 80), grosorbor=1, detalle=1, espesor=1) ww, hh = self.user.get_tamanio() w, h = G.RESOLUCION self.user.set_posicion(punto=(w - ww - 10, 25)) self.user.connect(callback=None, sonido_select=None) self.add(self.user) imagen = G.get_Flecha() self.flecha = JAMButton("", None) self.flecha.set_imagen(origen=imagen, tamanio=(100, 55)) self.flecha.set_colores(colorbas=JAMG.get_negro(), colorcara=JAMG.get_negro()) self.flecha.set_tamanios(tamanio=(0, 0), grosorbor=1, detalle=1, espesor=1) self.flecha.set_posicion(punto=(10, 10)) self.flecha.connect(callback=self.main.run_dialog_game) self.add(self.flecha) x, y = self.flecha.posicion w, h = self.flecha.get_tamanio() x += w ancho = G.RESOLUCION[0] / 2 - x cartel_titulo = pygame.sprite.Sprite() cartel_titulo.image = G.get_Imagen_Cartel1() cartel_titulo.image = pygame.transform.scale( cartel_titulo.image.copy(), (ancho, cartel_titulo.image.get_size()[1])) cartel_titulo.rect = cartel_titulo.image.get_rect() cartel_titulo.rect.x = x cartel_titulo.rect.y = -60 self.add(cartel_titulo) self.titulo = JAMLabel(self.main.nombre) self.titulo.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() self.titulo.set_font_from_file(fuente, tamanio=40) w, h = G.RESOLUCION x, y = (cartel_titulo.rect.x + 50, 10) self.titulo.set_posicion(punto=(x, y)) self.add(self.titulo) self.puntaje = JAMLabel("%s" % (self.main.puntos)) self.puntaje.set_text(color=JAMG.get_blanco()) fuente, tamanio = JAMG.get_Font_fawn() self.puntaje.set_font_from_file(fuente, tamanio=40) w, h = G.RESOLUCION self.add(self.puntaje) self.sonidos_reloj = G.get_sound_clock() from BiblioJAM.JAMCron import JAMCron self.cronometro = JAMCron() x, y = (0 - self.cronometro.cron.rect.w - 1, 0 - self.cronometro.cron.rect.h - 1) self.cronometro.cron.set_posicion(punto=(x, y)) self.cronometro.set_callback(self.main.game_over) self.cronometro.set_alarma(tiempo=(2, 30), duracion=3) self.add(self.cronometro) self.progress_reloj = ProgressBar(self.main) self.add(self.progress_reloj) self.decorativas = ImagenesDecorativas(self) self.add(self.decorativas)