Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/FGR_T0401.py
diff options
context:
space:
mode:
Diffstat (limited to 'FGR_T0401.py')
-rw-r--r--FGR_T0401.py154
1 files changed, 3 insertions, 151 deletions
diff --git a/FGR_T0401.py b/FGR_T0401.py
index b8e6f78..aaae838 100644
--- a/FGR_T0401.py
+++ b/FGR_T0401.py
@@ -22,8 +22,9 @@ import BiblioJAM.JAMGlobals as JAMG
class FGR_T0401(gtk.Widget):
__gsignals__ = {"run_grupo":(gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,gobject.TYPE_INT))}
- def __init__(self):
+ def __init__(self, usuario):
gtk.Widget.__init__(self)
+ self.usuario = usuario
self.ventana = None
self.nombre = "Niñas y niños pasajeros!"
self.estado = False
@@ -211,6 +212,7 @@ class FGR_T0401(gtk.Widget):
self.fondo1, self.fondo2= G.get_Fondos_FGR_T0401()
self.textos= Textos_Intro()
self.botonesmenu= ButtonsMenu(self)
+ from Globals import Controles
self.controles= Controles(self)
self.seniales= Seniales(self)
self.sonido_error, self.sonido_exito= G.get_Sonidos()
@@ -332,159 +334,9 @@ class FGR_T0401(gtk.Widget):
# ----------- EVENTOS en JUEGO ---------------
def salir(self, valor= None):
- '''
- if valor: self.estado= True
- if not valor: self.estado= False
- pygame.mixer.music.unpause()
- self.seniales.empty()
- self.controles.empty()'''
self.estado = False
self.emit("run_grupo", "grupo4", self.puntos)
-# -------- CONTROLES ----------
-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.recuadro_select= None
- self.progress_reloj= None
- self.sonidos_reloj= None
-
- self.load_sprites()
-
- def load_sprites(self):
- 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= (1,0), 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)
- w,h= G.RESOLUCION
- x,y= (w-self.puntaje.rect.w-20, 25)
- 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= G.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)
-# -------- CONTROLES ----------
-
# -------- SEÑALES ----------
class Seniales(pygame.sprite.OrderedUpdates):
''' Grupo de Señales. '''