diff pyntnclick/menu.py @ 548:ded4324b236e pyntnclick

Moved stuff around, broke everything.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 11 Feb 2012 13:10:18 +0200
parents gamelib/menu.py@42742a62f9c3
children 38fb04728ac5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pyntnclick/menu.py	Sat Feb 11 13:10:18 2012 +0200
@@ -0,0 +1,43 @@
+# menu.py
+# Copyright Boomslang team, 2010 (see COPYING File)
+# Main menu for the game
+
+from albow.screen import Screen
+from albow.resource import get_image
+
+from gamelib.widgets import BoomImageButton
+
+
+class SplashButton(BoomImageButton):
+
+    FOLDER = 'splash'
+
+
+class MenuScreen(Screen):
+    def __init__(self, shell):
+        Screen.__init__(self, shell)
+        self._background = get_image('splash', 'splash.png')
+        self._start_button = SplashButton('play.png', 16, 523, self.start)
+        self._resume_button = SplashButton('resume.png', 256, 523, self.resume,
+                                           enable=self.check_running)
+        self._quit_button = SplashButton('quit.png', 580, 523, shell.quit)
+        self.add(self._start_button)
+        self.add(self._resume_button)
+        self.add(self._quit_button)
+
+    def draw(self, surface):
+        surface.blit(self._background, (0, 0))
+        self._start_button.draw(surface)
+        self._resume_button.draw(surface)
+        self._quit_button.draw(surface)
+
+    def start(self):
+        self.shell.game_screen.start_game()
+        self.shell.show_screen(self.shell.game_screen)
+
+    def check_running(self):
+        return self.shell.game_screen.running
+
+    def resume(self):
+        if self.shell.game_screen.running:
+            self.shell.show_screen(self.shell.game_screen)