# HG changeset patch # User Neil Muller # Date 1329050706 -7200 # Node ID 363b603794f51b7583b47735d197f68ce601c74d # Parent 2703924c8c70a932966c5a19d9785a75229d5202 Re-add animations (and also fix some enter/leave event stuff) diff -r 2703924c8c70 -r 363b603794f5 pyntnclick/engine.py --- a/pyntnclick/engine.py Sun Feb 12 14:25:27 2012 +0200 +++ b/pyntnclick/engine.py Sun Feb 12 14:45:06 2012 +0200 @@ -48,6 +48,8 @@ ev.data) else: self._screen.dispatch(ev) + # Ping the screen / scene + self._screen.animate() surface = pygame.display.get_surface() self._screen.draw(surface) flip() @@ -88,6 +90,12 @@ def dispatch(self, ev): self.container.event(ev) + def animate(self): + """Called every tick - used for peroidic events, etc. + + Interested classes are expected to override this""" + pass + def draw_background(self): self.surface.fill(pygame.Color('gray')) diff -r 2703924c8c70 -r 363b603794f5 pyntnclick/gamescreen.py --- a/pyntnclick/gamescreen.py Sun Feb 12 14:25:27 2012 +0200 +++ b/pyntnclick/gamescreen.py Sun Feb 12 14:45:06 2012 +0200 @@ -127,6 +127,10 @@ # of what happens result = self.game.check_enter_leave(self.screen) handle_result(result, self) + if self.game.current_detail: + self.game.current_detail.animate() + else: + self.game.current_scene.animate() def mouse_move(self, event, widget): if self.game.current_detail: @@ -275,6 +279,7 @@ self.running = False self.create_initial_state = self.gd.initial_state self.container.add_callback(KEYDOWN, self.key_pressed) + self.state_widget = None def _clear_all(self): for widget in self.container.children[:]: @@ -299,6 +304,11 @@ self.running = True + def animate(self): + """Animate the state widget""" + if self.state_widget: + self.state_widget.animate() + def key_pressed(self, event, widget): if event.key == K_ESCAPE: self.change_screen('menu')