comparison pyntnclick/main.py @ 600:fabce47e542f pyntnclick

Stop using albow (at least for the menu). Breaks the world. Please fix it, kthx
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 11 Feb 2012 19:56:30 +0200
parents 2d2ea51b73ad
children 3ce19d33b51f
comparison
equal deleted inserted replaced
599:2d2ea51b73ad 600:fabce47e542f
14 14
15 import pygame 15 import pygame
16 from pygame.locals import SWSURFACE 16 from pygame.locals import SWSURFACE
17 from albow.shell import Shell 17 from albow.shell import Shell
18 18
19 from pyntnclick.engine import Engine
19 from pyntnclick.gamescreen import GameScreen, DefMenuScreen, DefEndScreen 20 from pyntnclick.gamescreen import GameScreen, DefMenuScreen, DefEndScreen
20 from pyntnclick.constants import GameConstants, DEBUG_ENVVAR 21 from pyntnclick.constants import GameConstants, DEBUG_ENVVAR
21 from pyntnclick.resources import Resources 22 from pyntnclick.resources import Resources
22 from pyntnclick.sound import Sound 23 from pyntnclick.sound import Sound
23 from pyntnclick import state 24 from pyntnclick import state
24 25
25 from pyntnclick.tools.rect_drawer import RectApp, make_rect_display 26 from pyntnclick.tools.rect_drawer import RectApp, make_rect_display
26 from pyntnclick.tools.utils import list_scenes 27 from pyntnclick.tools.utils import list_scenes
27
28
29 class MainShell(Shell):
30 # Should we allow the menu not to be the opening screen?
31 def __init__(self, display, game_description, menu_screen, end_screen):
32 Shell.__init__(self, display)
33 if menu_screen:
34 self.menu_screen = menu_screen(self, game_description)
35 else:
36 self.menu_screen = DefMenuScreen(self, game_description)
37 self.game_screen = GameScreen(self, game_description)
38 if end_screen:
39 self.end_screen = end_screen(self, game_description)
40 else:
41 self.end_screen = DefEndScreen(self, game_description)
42 self.set_timer(game_description.constants.frame_rate)
43 self.show_screen(self.menu_screen)
44 28
45 29
46 class GameDescriptionError(Exception): 30 class GameDescriptionError(Exception):
47 """Raised when an GameDescription is invalid.""" 31 """Raised when an GameDescription is invalid."""
48 32
54 38
55 # list of game scenes 39 # list of game scenes
56 SCENE_LIST = None 40 SCENE_LIST = None
57 41
58 # starting menu 42 # starting menu
59 MENU_SCREEN = None 43 MENU_SCREEN = DefMenuScreen
60 44
61 # game over screen 45 # game over screen
62 END_SCREEN = None 46 END_SCREEN = DefEndScreen
63 47
64 48
65 # resource module 49 # resource module
66 RESOURCE_MODULE = "Resources" 50 RESOURCE_MODULE = "Resources"
67 51
152 if opts.scene is None: 136 if opts.scene is None:
153 print 'Need to supply a scene to use the rect drawer' 137 print 'Need to supply a scene to use the rect drawer'
154 sys.exit(1) 138 sys.exit(1)
155 display = make_rect_display() 139 display = make_rect_display()
156 try: 140 try:
157 shell = RectApp(display, self.initial_state, opts.scene, 141 engine = RectApp(display, self.initial_state, opts.scene,
158 opts.detail) 142 opts.detail)
159 except KeyError: 143 except KeyError:
160 print 'Invalid scene: %s' % opts.scene 144 print 'Invalid scene: %s' % opts.scene
161 sys.exit(1) 145 sys.exit(1)
162 else: 146 else:
163 display = pygame.display.set_mode(self.constants.screen, 147 pygame.display.set_mode(self.constants.screen, SWSURFACE)
164 SWSURFACE)
165 pygame.display.set_icon(self.resource.get_image( 148 pygame.display.set_icon(self.resource.get_image(
166 'suspended_sentence24x24.png', basedir='icons')) 149 'suspended_sentence24x24.png', basedir='icons'))
167 pygame.display.set_caption("Suspended Sentence") 150 pygame.display.set_caption("Suspended Sentence")
168 151
169 shell = MainShell(display, self, self.MENU_SCREEN, 152 engine = Engine(self)
170 self.END_SCREEN) 153 # Should we allow the menu not to be the opening screen?
154 engine.set_screen(self.MENU_SCREEN(self))
171 try: 155 try:
172 shell.run() 156 engine.run()
173 except KeyboardInterrupt: 157 except KeyboardInterrupt:
174 pass 158 pass