Mercurial > rinkhals
comparison gamelib/engine.py @ 504:393e30ea0165
Save game loading working again.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Thu, 26 Nov 2009 22:28:22 +0000 |
parents | e0b11d684ee8 |
children | b112bcf4d435 |
comparison
equal
deleted
inserted
replaced
503:4c281ce4fc5f | 504:393e30ea0165 |
---|---|
38 | 38 |
39 def create_game_board(self): | 39 def create_game_board(self): |
40 """Create and open a gameboard window.""" | 40 """Create and open a gameboard window.""" |
41 self.gameboard = gameboard.GameBoard(self.main_app, | 41 self.gameboard = gameboard.GameBoard(self.main_app, |
42 self.level) | 42 self.level) |
43 self.open_window(self.gameboard.get_top_widget()) | |
44 | |
45 def switch_gameboard(self, gameboard): | |
46 """Switch over to a new gameboard.""" | |
47 self.gameboard = gameboard | |
48 self.gameboard.disp = self.main_app | |
49 self.gameboard.create_display() | |
43 self.open_window(self.gameboard.get_top_widget()) | 50 self.open_window(self.gameboard.get_top_widget()) |
44 | 51 |
45 def set_main_menu(self): | 52 def set_main_menu(self): |
46 """Open the main menu""" | 53 """Open the main menu""" |
47 self.scoreboard = gameover.ScoreTable(self.level) | 54 self.scoreboard = gameover.ScoreTable(self.level) |
187 self.dialog = check_exit() | 194 self.dialog = check_exit() |
188 elif e.type is KEYDOWN and e.key == K_n: | 195 elif e.type is KEYDOWN and e.key == K_n: |
189 return pygame.event.post(START_NIGHT) | 196 return pygame.event.post(START_NIGHT) |
190 elif events_equal(e, GO_MAIN_MENU): | 197 elif events_equal(e, GO_MAIN_MENU): |
191 return MainMenuState(self.game) | 198 return MainMenuState(self.game) |
199 elif e.type is DO_LOAD_SAVEGAME: | |
200 self.game.switch_gameboard(e.gameboard) | |
201 return | |
192 elif e.type is not QUIT: | 202 elif e.type is not QUIT: |
193 self.game.main_app.event(e) | 203 self.game.main_app.event(e) |
194 | 204 |
195 def paint(self, screen): | 205 def paint(self, screen): |
196 self.game.main_app.paint(screen) | 206 self.game.main_app.paint(screen) |
318 GO_LEVEL_SCREEN = pygame.event.Event(USEREVENT, name="GO_LEVEL_SCREEN") | 328 GO_LEVEL_SCREEN = pygame.event.Event(USEREVENT, name="GO_LEVEL_SCREEN") |
319 DO_LOAD_LEVEL = pygame.event.Event(USEREVENT, name="DO_LEVEL_SCREEN") | 329 DO_LOAD_LEVEL = pygame.event.Event(USEREVENT, name="DO_LEVEL_SCREEN") |
320 FAST_FORWARD = pygame.event.Event(USEREVENT, name="FAST_FORWARD") | 330 FAST_FORWARD = pygame.event.Event(USEREVENT, name="FAST_FORWARD") |
321 MOVE_FOX_ID = USEREVENT + 1 | 331 MOVE_FOX_ID = USEREVENT + 1 |
322 MOVE_FOXES = pygame.event.Event(MOVE_FOX_ID, name="MOVE_FOXES") | 332 MOVE_FOXES = pygame.event.Event(MOVE_FOX_ID, name="MOVE_FOXES") |
333 DO_LOAD_SAVEGAME = USEREVENT + 2 | |
323 QUIT = pygame.event.Event(QUIT) | 334 QUIT = pygame.event.Event(QUIT) |
324 | 335 |
325 # Due to the way pgu's loop timing works, these will only get proceesed | 336 # Due to the way pgu's loop timing works, these will only get proceesed |
326 # at intervals of 10ms, so there's no point in them not being multiples of 10 | 337 # at intervals of 10ms, so there's no point in them not being multiples of 10 |
327 FAST__SPEED=80 | 338 FAST__SPEED=80 |