changeset 24:9d5de13e2ac3

Add a game screen. So far, the game content looks a *lot* like the main menu.
author Jeremy Thurgood <firxen@gmail.com>
date Sun, 22 Aug 2010 18:09:25 +0200
parents 1e90a3e4618e
children f9e697e0c6ba
files gamelib/gamescreen.py gamelib/main.py gamelib/menu.py
diffstat 3 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gamelib/gamescreen.py	Sun Aug 22 18:09:25 2010 +0200
@@ -0,0 +1,27 @@
+# menu.py
+# Copyright Boomslang team, 2010 (see COPYING File)
+# Main menu for the game
+
+from albow.screen import Screen
+from albow.controls import Button, Label
+from albow.layout import Column
+
+class GameScreen(Screen):
+    def __init__(self, shell):
+        Screen.__init__(self, shell)
+        self.shell = shell
+        StartButton = Button('Main Menu', action = self.main_menu)
+        QuitButton = Button('Quit', action = shell.quit)
+        Title = Label('Caught! ... In SPAACE')
+        menu = Column([
+            Title,
+            StartButton,
+            QuitButton,
+            ], align='l', spacing=20)
+        self.add_centered(menu)
+
+    def main_menu(self):
+        print 'Returning to menu'
+        self.shell.show_screen(self.shell.menu_screen)
+
+
--- a/gamelib/main.py	Sun Aug 22 18:07:48 2010 +0200
+++ b/gamelib/main.py	Sun Aug 22 18:09:25 2010 +0200
@@ -11,12 +11,14 @@
 from albow.dialogs import alert
 from albow.shell import Shell
 from menu import MenuScreen
+from gamescreen import GameScreen
 from constants import SCREEN
 
 class MainShell(Shell):
     def __init__(self, display):
         Shell.__init__(self, display)
         self.menu_screen = MenuScreen(self)
+        self.game_screen = GameScreen(self)
         self.show_screen(self.menu_screen)
 
 def main():
--- a/gamelib/menu.py	Sun Aug 22 18:07:48 2010 +0200
+++ b/gamelib/menu.py	Sun Aug 22 18:09:25 2010 +0200
@@ -9,7 +9,8 @@
 class MenuScreen(Screen):
     def __init__(self, shell):
         Screen.__init__(self, shell)
-        StartButton  = Button('Start New Game', action = self.start)
+        self.shell = shell
+        StartButton = Button('Start New Game', action = self.start)
         QuitButton = Button('Quit', action = shell.quit)
         Title = Label('Caught! ... In SPAACE')
         menu = Column([
@@ -21,5 +22,6 @@
 
     def start(self):
         print 'Starting the game'
+        self.shell.show_screen(self.shell.game_screen)