diff pyntnclick/main.py @ 553:ebb2efcb4ea7 pyntnclick

Create a re-usable main function.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 11 Feb 2012 13:40:51 +0200
parents 38fb04728ac5
children 99a1420097df
line wrap: on
line diff
--- a/pyntnclick/main.py	Sat Feb 11 13:30:56 2012 +0200
+++ b/pyntnclick/main.py	Sat Feb 11 13:40:51 2012 +0200
@@ -39,16 +39,16 @@
 
 
 class MainShell(Shell):
-    def __init__(self, display):
+    def __init__(self, display, initial_state):
         Shell.__init__(self, display)
         self.menu_screen = MenuScreen(self)
-        self.game_screen = GameScreen(self)
+        self.game_screen = GameScreen(self, initial_state)
         self.end_screen = EndScreen(self)
         self.set_timer(FRAME_RATE)
         self.show_screen(self.menu_screen)
 
 
-def main():
+def main(initial_scene, scene_list, debug_rects=False):
     opts = parse_args(sys.argv)
     pygame.display.init()
     pygame.font.init()
@@ -63,13 +63,15 @@
     if DEBUG:
         if opts.scene is not None:
             # debug the specified scene
-            state.DEBUG_SCENE = opts.scene
-        state.DEBUG_RECTS = opts.rects
+            initial_scene = opts.scene
+        debug_rects = opts.rects
+    initial_state = state.initial_state_creator(initial_scene, scene_list,
+                                                debug_rects)
     display = pygame.display.set_mode(SCREEN, SWSURFACE)
     pygame.display.set_icon(pygame.image.load(
         data.filepath('icons/suspended_sentence24x24.png')))
     pygame.display.set_caption("Suspended Sentence")
-    shell = MainShell(display)
+    shell = MainShell(display, initial_state)
     try:
         shell.run()
     except KeyboardInterrupt: