changeset 581:7e4a20eb78b8 pyntnclick

Pass game_description to all screens
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 11 Feb 2012 16:28:41 +0200
parents 27809609eeca
children 522afd63090c
files pyntnclick/endscreen.py pyntnclick/gamescreen.py pyntnclick/main.py pyntnclick/menu.py
diffstat 4 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pyntnclick/endscreen.py	Sat Feb 11 16:22:56 2012 +0200
+++ b/pyntnclick/endscreen.py	Sat Feb 11 16:28:41 2012 +0200
@@ -14,7 +14,7 @@
 
 
 class EndScreen(Screen):
-    def __init__(self, shell):
+    def __init__(self, shell, game_description):
         Screen.__init__(self, shell)
         self.background = get_image('won', 'won.png')
         self._menu_button = EndImageButton('menu.png', 26, 500,
--- a/pyntnclick/gamescreen.py	Sat Feb 11 16:22:56 2012 +0200
+++ b/pyntnclick/gamescreen.py	Sat Feb 11 16:28:41 2012 +0200
@@ -208,11 +208,11 @@
 
 
 class GameScreen(Screen, CursorWidget):
-    def __init__(self, shell, create_initial_state):
+    def __init__(self, shell, game_description):
         CursorWidget.__init__(self, self)
         Screen.__init__(self, shell)
         self.running = False
-        self.create_initial_state = create_initial_state
+        self.create_initial_state = game_description.initial_state
 
     def _clear_all(self):
         for widget in self.subwidgets[:]:
--- a/pyntnclick/main.py	Sat Feb 11 16:22:56 2012 +0200
+++ b/pyntnclick/main.py	Sat Feb 11 16:28:41 2012 +0200
@@ -26,12 +26,12 @@
 
 
 class MainShell(Shell):
-    def __init__(self, display, initial_state, frame_rate):
+    def __init__(self, display, game_description):
         Shell.__init__(self, display)
-        self.menu_screen = MenuScreen(self)
-        self.game_screen = GameScreen(self, initial_state)
-        self.end_screen = EndScreen(self)
-        self.set_timer(frame_rate)
+        self.menu_screen = MenuScreen(self, game_description)
+        self.game_screen = GameScreen(self, game_description)
+        self.end_screen = EndScreen(self, game_description)
+        self.set_timer(game_description.constants.frame_rate)
         self.show_screen(self.menu_screen)
 
 
@@ -107,8 +107,7 @@
         pygame.display.set_icon(self.resource.load_image(
                 'suspended_sentence24x24.png', basedir='icons'))
         pygame.display.set_caption("Suspended Sentence")
-        shell = MainShell(display, self.initial_state,
-                          self.constants.frame_rate)
+        shell = MainShell(display, self)
         try:
             shell.run()
         except KeyboardInterrupt:
--- a/pyntnclick/menu.py	Sat Feb 11 16:22:56 2012 +0200
+++ b/pyntnclick/menu.py	Sat Feb 11 16:28:41 2012 +0200
@@ -14,7 +14,7 @@
 
 
 class MenuScreen(Screen):
-    def __init__(self, shell):
+    def __init__(self, shell, game_description):
         Screen.__init__(self, shell)
         self._background = get_image('splash', 'splash.png')
         self._start_button = SplashButton('play.png', 16, 523, self.start)