Skip to content

Commit

Permalink
Famoso http://tareas.somosazucar.org/ple/issue17 resuelto (estabilidad)
Browse files Browse the repository at this point in the history
  • Loading branch information
icarito committed Feb 2, 2015
1 parent 75785ff commit cd1cdcf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
31 changes: 16 additions & 15 deletions GameView.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from ConfigParser import SafeConfigParser
from Globales import COLORES


class GameMenu(gtk.EventBox):

__gsignals__ = {
Expand Down Expand Up @@ -115,9 +114,9 @@ def run(self, topic):
self.gameview.hide()

def start_game(self, widget, index):
self.gameview.run(self.topic, index)
self.inside_vb.hide()
self.titulo.hide()
self.gameview.run(self.topic, index)

def __decolor(self, widget, event):
widget.get_image().set_from_file("Imagenes/go_back_disabled.png")
Expand All @@ -144,10 +143,10 @@ def __init__(self):

self.game = False
self.pump = False
self.firstrun = True

self.pygamecanvas = sugargame2.canvas.PygameCanvas(self)


grupo1 = gtk.Alignment(0.5, 1, 0, 0)
separador = gtk.HSeparator()
grupo1.add(separador)
Expand Down Expand Up @@ -242,6 +241,7 @@ def __run_game_1(self):

rect = self.get_allocation()
self.lado = min(rect.width-8, rect.height-8)
print self.lado
self.pygamecanvas.set_size_request(self.lado, self.lado)
spyral.director.init((self.lado, self.lado),
fullscreen=False, max_fps=30)
Expand All @@ -261,6 +261,7 @@ def __run_game_2(self):

rect = self.get_allocation()
self.lado = min(rect.width-8, rect.height-8)
print self.lado
self.pygamecanvas.set_size_request(self.lado, self.lado)
spyral.director.init((self.lado, self.lado),
fullscreen=False, max_fps=30)
Expand All @@ -280,6 +281,7 @@ def __run_game_3(self):

rect = self.get_allocation()
self.lado = min(rect.width-8, rect.height-8)
print self.lado
self.pygamecanvas.set_size_request(self.lado, self.lado)
spyral.director.init((self.lado, self.lado),
fullscreen=False, max_fps=30)
Expand All @@ -303,27 +305,26 @@ def stop(self):
gobject.source_remove(self.pump)
self.pump = False
if self.game:
try:
pygame.event.clear()
spyral.quit()
del(self.game)
except spyral.exceptions.GameEndException, pygame.error:
pass
finally:
self.game = False
pygame.mixer.music.stop()
spyral.director.pop()
self.game = False
self.hide()

def run(self, topic, game):
self.update_score(0)
self.volbtn.set_active(False)
self.volbtn.get_image().set_from_file("Iconos/stock_volume-max.svg")
self.topic = topic
self.pygamecanvas.grab_focus()
self.show()
if game==0:
gamestart=self.__run_game_1
elif game==1:
gamestart=self.__run_game_2
elif game==2:
gamestart=self.__run_game_3
self.topic = topic
self.pygamecanvas.run_pygame(gamestart)
self.pygamecanvas.grab_focus()
self.show()
if self.firstrun:
self.firstrun = False
gobject.idle_add(self.pygamecanvas.run_pygame(gamestart))
else:
gobject.idle_add(gamestart())
9 changes: 8 additions & 1 deletion Lib/spyral/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
_max_fps = 30
_max_ups = 30

class NullScene(spyral.Scene):
def __init__(self, size):
spyral.Scene.__init__(self, size)
self.background = spyral.Image(size=size)

def quit():
"""
Cleanly quits out of spyral by emptying the stack.
Expand Down Expand Up @@ -131,7 +136,9 @@ def pop():
scene = _stack[-1]
spyral.event.handle('director.scene.enter', scene=scene)
else:
exit(0)
scene = NullScene((600,600))
_stack.append(scene)
#exit(0)
pygame.event.get()

def push(scene):
Expand Down

0 comments on commit cd1cdcf

Please sign in to comment.