Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/conozcoal.py
diff options
context:
space:
mode:
Diffstat (limited to 'conozcoal.py')
-rwxr-xr-x[-rw-r--r--]conozcoal.py49
1 files changed, 31 insertions, 18 deletions
diff --git a/conozcoal.py b/conozcoal.py
index 423e4ac..f21789b 100644..100755
--- a/conozcoal.py
+++ b/conozcoal.py
@@ -90,7 +90,11 @@ class Zona():
def estaAca(self,pos):
"""Devuelve True si la coordenada pos esta en la zona"""
if pos[0] < XMAPAMAX*scale+shift_x:
- colorAca = self.mapa.get_at((pos[0]-shift_x, pos[1]-shift_y))
+ try:
+ colorAca = self.mapa.get_at((int(pos[0]-shift_x),
+ int(pos[1]-shift_y)))
+ except: # probablemente click fuera de la imagen
+ return False
if colorAca[0] == self.claveColor:
return True
else:
@@ -105,7 +109,7 @@ class Zona():
textrect = textrot.get_rect()
textrect.center = (self.posicion[0], self.posicion[1])
pantalla.blit(textrot, textrect)
- if flipAhora:
+ if flipAhora:
pygame.display.flip()
@@ -141,7 +145,7 @@ class Nivel():
def devolverAyuda(self):
"""Devuelve la linea de ayuda"""
- self.preguntaActual = self.preguntas[self.indicePreguntaActual-1]
+ self.preguntaActual = self.preguntas[self.indicePreguntaActual-1]
return self.preguntaActual[2].split("\\")
def mostrarPregunta(self,pantalla,fuente,sufijo,prefijo):
@@ -157,7 +161,7 @@ class Nivel():
textrect.center = (XCENTROPANEL,yLinea)
pantalla.blit(text, textrect)
yLinea = yLinea + fuente.get_height()
- pygame.display.flip()
+ pygame.display.flip()
class ConozcoAl():
@@ -216,7 +220,7 @@ class ConozcoAl():
continue
if linea.find("=") == -1:
linea = f.readline()
- continue
+ continue
[var,valor] = linea.strip().split("=")
if var.startswith("Prefijo"):
self.listaPrefijos.append(
@@ -282,11 +286,12 @@ class ConozcoAl():
(int(600*scale+shift_x),
int(800*scale+shift_y)),
(255,155,155))
- pygame.display.flip()
+ pygame.display.flip()
while 1:
for event in wait_events():
if event.type == pygame.KEYDOWN:
- self.click.play()
+ if self.sound:
+ self.click.play()
self.pantalla.blit(self.pantallaTemp,(0,0))
pygame.display.flip()
return
@@ -339,11 +344,13 @@ class ConozcoAl():
for event in wait_events():
if event.type == pygame.KEYDOWN:
if event.key == 27: # escape: volver
- self.click.play()
+ if self.sound:
+ self.click.play()
self.elegir_directorio = True
return
elif event.type == pygame.MOUSEBUTTONDOWN:
- self.click.play()
+ if self.sound:
+ self.click.play()
pos = event.pos
if pos[1] > 275*scale + shift_y: # zona de opciones
if pos[0] < 600*scale + shift_x: # primera columna
@@ -415,14 +422,18 @@ class ConozcoAl():
self.camino_sonidos = os.path.join(CAMINORECURSOS,
CAMINOCOMUN,
CAMINOSONIDOS)
- self.click = pygame.mixer.Sound(os.path.join(\
- self.camino_sonidos,"junggle_btn045.wav"))
- self.click.set_volume(0.2)
+ self.sound = True
+ try:
+ self.click = pygame.mixer.Sound(os.path.join(\
+ self.camino_sonidos,"junggle_btn045.wav"))
+ self.click.set_volume(0.2)
+ except:
+ self.sound = False
# cargar fuentes
self.fuente48 = pygame.font.Font(os.path.join(CAMINORECURSOS,\
CAMINOCOMUN,\
CAMINOFUENTES,\
- "AllCaps.ttf"),
+ "Share-Regular.ttf"),
int(48*scale))
self.fuente40 = pygame.font.Font(os.path.join(CAMINORECURSOS,\
CAMINOCOMUN,\
@@ -490,7 +501,7 @@ class ConozcoAl():
textrect.center = (int(XCENTROPANEL*scale+shift_x),yLinea)
self.pantalla.blit(text, textrect)
yLinea = yLinea + self.fuente32.get_height() + int(10*scale)
- pygame.display.flip()
+ pygame.display.flip()
def borrarGlobito(self):
""" Borra el globito, lo deja en blanco"""
@@ -506,7 +517,7 @@ class ConozcoAl():
self.mostrarGlobito([self.listaCorrecto[self.correctoActual]])
self.esCorrecto = True
pygame.time.set_timer(EVENTORESPUESTA,TIEMPORESPUESTA)
-
+
def mal(self):
"""Muestra texto en el globito cuando la respuesta es incorrecta"""
self.malActual = random.randint(1,self.numeroMal)-1
@@ -556,11 +567,13 @@ class ConozcoAl():
for event in wait_events():
if event.type == pygame.KEYDOWN:
if event.key == 27: # escape: salir
- self.click.play()
+ if self.sound:
+ self.click.play()
pygame.time.set_timer(EVENTORESPUESTA,0)
return
elif event.type == pygame.MOUSEBUTTONDOWN:
- self.click.play()
+ if self.sound:
+ self.click.play()
if self.avanceNivel < TOTALAVANCE:
if event.pos[0] < XMAPAMAX*scale+shift_x: # zona mapa
self.borrarGlobito()
@@ -629,7 +642,7 @@ class ConozcoAl():
pygame.display.flip()
# ir al juego
self.jugarNivel()
-
+
def main():
juego = ConozcoAl()