From b4e54fc9a2b3955689e48c02402d8090516ccae1 Mon Sep 17 00:00:00 2001 From: flavio Date: Fri, 06 Apr 2012 20:53:07 +0000 Subject: Correcciones --- (limited to 'Globals.py') diff --git a/Globals.py b/Globals.py index 73556de..40d2479 100644 --- a/Globals.py +++ b/Globals.py @@ -18,6 +18,11 @@ import shelve from pygame.locals import * gc.enable() +import BiblioJAM +from BiblioJAM.JAMButton import JAMButton +from BiblioJAM.JAMLabel import JAMLabel +import BiblioJAM.JAMGlobals as JAMG + GRIS = gtk.gdk.Color(60156, 60156, 60156, 1) AMARILLO1 = gtk.gdk.Color(65000,65000,40275,1) NARANJA = gtk.gdk.Color(65000,26000,0,1) @@ -120,7 +125,6 @@ def get_sound_clock(): def get_instruc(name): imagen = os.path.join(IMAGENES, "Instructivos/%s.jpg" % (name)) return pygame.transform.scale(pygame.image.load(imagen), RESOLUCION) - #return pygame.transform.scale(pygame.image.load(DIRECTORIO_BASE+"/Imagenes/Instructivos/%s.jpg" % (name)), RESOLUCION) def get_Presentacion(): directorio = os.path.join(IMAGENES, "Presentacion") imagenes = [] @@ -802,7 +806,7 @@ def get_Fondos_FGR_T0503(): return (fondo1, fondo2) def get_Texto_FGR_T0503(): return [ - "1- Papa y mama lo usan cuando cae el sol para", + "1- Papá y mamá lo usan cuando cae el sol para", " ir en moto o caminar por la ruta", "2- Cuando vamos de paseo, mamá y papá nunca", " lo olvidan, pero en el auto, no lo usan JAMÁS!", @@ -820,3 +824,153 @@ def get_Texto_FGR_T0503(): "8- En el auto y en mi bicicleta, debo", " asegurarme que funcione correctamente la . . ."] +class Controles(pygame.sprite.OrderedUpdates): + def __init__(self, main): + pygame.sprite.OrderedUpdates.__init__(self) + self.main = main + self.flecha = None + self.titulo = None + self.puntaje = None + self.cronometro = None + self.progress_reloj = None + self.sonidos_reloj = None + self.user = None + + self.load_sprites() + + 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 = RESOLUCION + self.user.set_posicion(punto = (w - ww - 10, 25)) + self.user.connect(callback = None, sonido_select = None) + self.add(self.user) + + imagen= 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= RESOLUCION[0]/2 - x + cartel_titulo= pygame.sprite.Sprite() + cartel_titulo.image= 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= 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= RESOLUCION + self.add(self.puntaje) + + self.sonidos_reloj= 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 = (1,30), duracion = 3) + self.add(self.cronometro) + + self.progress_reloj= ProgressBar(self.main) + self.add(self.progress_reloj) + + def actualiza_puntos(self): + puntos = "%s" %(self.main.puntos) + self.puntaje.set_text(texto= puntos) + x,y = self.user.get_posicion() + w,h = self.puntaje.get_tamanio() + x -= w+10 + self.puntaje.set_posicion(punto= (x,y)) + + def switching_game(self, button): + self.main.estado= "Intro" + return self.main.run() + + def init(self): + sound= self.sonidos_reloj[0] + self.cronometro.set_sound(sound) + self.cronometro.reset() + self.actualiza_puntos() + self.cronometro.play() + def stop(self): + self.cronometro.pause() + def play(self): + self.cronometro.play() + +class ProgressBar(pygame.sprite.Sprite): + def __init__(self, main): + pygame.sprite.Sprite.__init__(self) + self.main = main + self.acumula = 0 + w,h = RESOLUCION + self.tamanio = (w/2-10,10) + self.posicion = (w/2,10) + rect1 = JAMG.get_Rectangulo( JAMG.get_verde1(), self.tamanio) + w,y = rect1.get_size() + a = w/6*3 + rect2 = JAMG.get_Rectangulo( JAMG.get_amarillo1(), (a,self.tamanio[1])) + imagen = JAMG.pegar_imagenes_alineado_derecha(rect2, rect1) + a = w/6 + rect3 = JAMG.get_Rectangulo( JAMG.get_rojo1(), (a,self.tamanio[1])) + self.imagen_original = JAMG.pegar_imagenes_alineado_derecha(rect3, imagen) + self.image = self.imagen_original.copy() + self.rect = self.image.get_rect() + self.rect.x, self.rect.y= self.posicion + + def update(self): + tiempo = self.main.controles.cronometro.cron.segundos_final + transcurridos = self.main.controles.cronometro.get_tiempo_transcurrido() + faltan = self.main.controles.cronometro.cron.segundos_faltan + mitad = tiempo/2 + cuarto = tiempo/4 + if faltan <= mitad: + if faltan > cuarto: + if not self.main.controles.cronometro.sonido == self.main.controles.sonidos_reloj[1]: + self.main.controles.stop() + self.main.controles.cronometro.set_sound(self.main.controles.sonidos_reloj[1]) + self.main.controles.play() + elif faltan <= cuarto: + if not self.main.controles.cronometro.sonido == self.main.controles.sonidos_reloj[2]: + self.main.controles.stop() + self.main.controles.cronometro.set_sound(self.main.controles.sonidos_reloj[2]) + self.main.controles.play() + ancho, alto = self.tamanio + ind = float(float(ancho)/float(self.main.controles.cronometro.cron.segundos_final)) + ancho = float(float(ancho)- float(self.main.controles.cronometro.get_tiempo_transcurrido())*ind) + dif = float(float(self.tamanio[0]) - float(ancho)) + try: + self.image = self.imagen_original.copy().subsurface((dif,0,int(ancho), int(alto))) + except: + self.image = self.imagen_original.copy().subsurface((dif,0,0,0)) + self.rect = self.image.get_rect() + x,y = self.posicion + x += dif + self.rect.x, self.rect.y= (x,y) + -- cgit v0.9.1