Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/FGR_T0202.py
diff options
context:
space:
mode:
Diffstat (limited to 'FGR_T0202.py')
-rw-r--r--FGR_T0202.py192
1 files changed, 4 insertions, 188 deletions
diff --git a/FGR_T0202.py b/FGR_T0202.py
index a0b1a1e..448325c 100644
--- a/FGR_T0202.py
+++ b/FGR_T0202.py
@@ -22,8 +22,9 @@ import BiblioJAM.JAMGlobals as JAMG
class FGR_T0202(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 = "Caminando a la Escuela II"
self.estado = False
@@ -106,8 +107,6 @@ class FGR_T0202(gtk.Widget):
self.controles.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
- #self.victory()
- #self.game_over(None)
def reset(self):
self.puntos= 0
@@ -128,25 +127,20 @@ class FGR_T0202(gtk.Widget):
self.controles.stop()
self.puntos+= (10*self.controles.cronometro.get_tiempo_restante())
self.controles.actualiza_puntos()
-
self.ventana.blit(self.fondo, (0,0))
self.seniales.draw(self.ventana)
self.controles.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
pygame.time.wait(1000)
-
text1= "Excelente, Arturo les agradece su ayuda. Por haber contestado correctamente y haber"
text2= "ayudado a Arturo se ganaron 2 stickers. Les falta sólo 1 para completar este nivel."
-
mensaje= Mensaje(self, "Victory", text1, text2)
self.fondo= self.fondo1
-
self.ventana.blit(self.fondo, (0,0))
mensaje.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
while mensaje.estado == True:
self.reloj.tick(35)
mensaje.clear(self.ventana, self.fondo)
@@ -154,7 +148,6 @@ class FGR_T0202(gtk.Widget):
mensaje.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
pygame.time.wait(6000)
return self.salir(True)
@@ -163,25 +156,20 @@ class FGR_T0202(gtk.Widget):
self.controles.update() # para actualizar imagen de progressbar del reloj
self.controles.stop()
self.controles.actualiza_puntos()
-
self.ventana.blit(self.fondo, (0,0))
self.seniales.draw(self.ventana)
self.controles.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
pygame.time.wait(1000)
-
text1= "Te han Faltado Unos Segundos Para Completar la Actividad."
text2= "Prueba Nuevamente."
-
mensaje= Mensaje(self, "End", text1, text2)
self.fondo= self.fondo1
-
self.ventana.blit(self.fondo, (0,0))
mensaje.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
while mensaje.estado == True:
self.reloj.tick(35)
mensaje.clear(self.ventana, self.fondo)
@@ -189,7 +177,6 @@ class FGR_T0202(gtk.Widget):
mensaje.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
pygame.time.wait(6000)
return self.salir(False)
@@ -209,7 +196,8 @@ class FGR_T0202(gtk.Widget):
self.fondo1, self.fondo2= G.get_Fondos_FGR_T0202()
self.textos= Textos_Intro()
self.botonesmenu= ButtonsMenu(self)
- self.controles= Controles(self)
+ from Globals import Controles
+ self.controles = Controles(self)
self.seniales= Seniales(self)
self.sonido_error, self.sonido_exito= G.get_Sonidos()
self.sound_select= JAMG.get_sound_select()
@@ -266,11 +254,9 @@ class FGR_T0202(gtk.Widget):
dialog.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
dialog.clear(self.ventana, self.fondo)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
def ok_intro(self, button):
return self.salir(False)
def cancel_intro(self, button):
@@ -311,7 +297,6 @@ class FGR_T0202(gtk.Widget):
dialog.draw(self.ventana)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
pygame.display.update()
-
if self.estado== "Intro":
dialog.clear(self.ventana, self.fondo)
self.ventana_real.blit(pygame.transform.scale(self.ventana, self.resolucionreal), (0,0))
@@ -330,159 +315,9 @@ class FGR_T0202(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", "grupo2", 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. '''
@@ -497,12 +332,10 @@ class Seniales(pygame.sprite.OrderedUpdates):
def load_sprites(self):
for afirmacion in G.get_afirmaciones_FGR_T0202():
self.afirmaciones.append(Afirmaciones(self, afirmacion))
-
boton= Sprite_Boton_afirmacion(self, "Verdadero", True)
self.botones.append(boton)
boton= Sprite_Boton_afirmacion(self, "Falso", False)
self.botones.append(boton)
-
w,h= (0,0)
for boton in self.botones:
w1,h1= boton.get_tamanio()
@@ -511,11 +344,9 @@ class Seniales(pygame.sprite.OrderedUpdates):
for boton in self.botones:
boton.set_tamanios(tamanio=(w,h), grosorbor=1, detalle=1, espesor=1)
boton.connect(callback= self.deja_en, sonido_select= None)
-
x,y,w,h= self.afirmaciones[0].sprite_imagen.rect
y+= h+20
x= G.RESOLUCION[0]/2 + 50
-
self.botones[1].set_posicion(punto= (x,y))
w1,h1= self.botones[0].get_tamanio()
self.botones[0].set_posicion(punto= (x-50-w1,y))
@@ -558,18 +389,15 @@ class Afirmaciones(pygame.sprite.OrderedUpdates):
pygame.sprite.OrderedUpdates.__init__(self)
self.main= main
imagen, afirmacion, valor= afirmacion
-
self.valor= valor
self.sprite_imagen= self.get_imagen_sprite(imagen)
self.label= self.get_labels(afirmacion)
-
self.add(self.sprite_imagen)
self.add(self.label)
def get_labels(self, afirmacion):
fuente, tamanio= JAMG.get_Font_fawn()
tamanio= 50
-
labels= []
textos= afirmacion.split("\n")
for t in textos:
@@ -577,7 +405,6 @@ class Afirmaciones(pygame.sprite.OrderedUpdates):
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:
@@ -612,12 +439,10 @@ class Textos_Intro(pygame.sprite.OrderedUpdates):
self.labels= []
self.gruber= None
self.base= None
-
self.load_textos()
self.set_posicion_labels()
self.base= self.get_base()
self.gruber= self.get_gruber()
-
self.add(self.base)
self.add(self.labels)
self.add(self.gruber)
@@ -684,7 +509,6 @@ class ButtonsMenu(pygame.sprite.OrderedUpdates):
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())
@@ -692,7 +516,6 @@ class ButtonsMenu(pygame.sprite.OrderedUpdates):
salir.set_posicion(punto= (10,10))
salir.connect (callback= self.main.run_dialog_intro)
self.add(salir)
-
jugar= JAMButton("Jugar",None)
jugar.set_text(color=JAMG.get_blanco())
fuente, tamanio= JAMG.get_Font_fawn()
@@ -723,27 +546,22 @@ class Mensaje(pygame.sprite.OrderedUpdates):
pygame.sprite.OrderedUpdates.__init__(self)
self.main= main
self.estado= True
-
self.base= None
self.label1= None
self.label2= None
self.labels= []
self.gruber= None
-
self.label1= Sprite_Texto(text1)
self.label2= Sprite_Texto(text2)
self.labels= [self.label1, self.label2]
-
self.x_final_label1= 0
self.x_final_label2= 0
-
self.init()
self.base= self.get_base()
if opcion== "Victory":
self.gruber= self.get_gruber2()
elif opcion== "End":
self.gruber= self.get_gruber3()
-
self.add(self.base)
self.add(self.labels)
self.add(self.gruber)
@@ -752,12 +570,10 @@ class Mensaje(pygame.sprite.OrderedUpdates):
w,h= G.RESOLUCION
w1,h1= (self.label1.rect.w, self.label1.rect.h)
w2,h2= (self.label2.rect.w, self.label2.rect.h)
-
x= 0-w
y= h/2-h2/2
self.label2.rect.x, self.label2.rect.y= (x,y)
self.x_final_label2= w/2-w2/2
-
x= w
y= self.label2.rect.y - h2
self.label1.rect.x, self.label1.rect.y= (x,y)