Mercurial > mamba
diff mamba/engine.py @ 51:e5f36843f7cd
Add on_enter and on_exit methods to habitats.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 11 Sep 2011 15:42:57 +0200 |
parents | 047273a63054 |
children | 3cc917814579 |
line wrap: on
line diff
--- a/mamba/engine.py Sun Sep 11 15:29:52 2011 +0200 +++ b/mamba/engine.py Sun Sep 11 15:42:57 2011 +0200 @@ -14,7 +14,11 @@ self._habitat = None def set_habitat(self, habitat): + if self._habitat is not None: + self._habitat.on_exit() self._habitat = habitat + if self._habitat is not None: + self._habitat.on_enter() def run(self): """Game loop.""" @@ -37,6 +41,14 @@ self.surface = pygame.Surface(SCREEN) self.container = Container() + def on_enter(self): + """Called when this becomes the current habitat.""" + pass + + def on_exit(self): + """Called when this stops being the current habitat.""" + pass + def dispatch(self, ev): self.container.event(ev)