Mercurial > pyntnclick
diff gamelib/state.py @ 126:f125bb60d7de
Move result handling to result object
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Tue, 24 Aug 2010 18:05:27 +0200 |
parents | d3ca34a664fd |
children | 9646e7c8bb97 |
line wrap: on
line diff
--- a/gamelib/state.py Tue Aug 24 18:01:42 2010 +0200 +++ b/gamelib/state.py Tue Aug 24 18:05:27 2010 +0200 @@ -2,7 +2,7 @@ from albow.resource import get_image from albow.utils import frame_rect -from widgets import BoomLabel +from widgets import BoomLabel, MessageDialog from pygame.locals import BLEND_ADD from pygame.rect import Rect from pygame.color import Color @@ -20,6 +20,16 @@ if soundfile: self.sound = get_sound(soundfile) + def process(self, scene): + """Helper function to do the right thing with a result object""" + if self.sound: + self.sound.play() + if self.message: + # Display the message as a modal dialog + MessageDialog(self.message, 60).present() + # queue a redraw to show updated state + scene.invalidate() + def initial_state(): """Load the initial state."""