From: Neil Date: Sat, 17 May 2014 21:37:10 +0000 (+0200) Subject: Add a dummygame scene X-Git-Tag: 0.1~15^2~5 X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=commitdiff_plain;h=05b45639ab5519bb3379269032d84bca9fb681b3 Add a dummygame scene --- diff --git a/naja/scenes/dummygame.py b/naja/scenes/dummygame.py new file mode 100644 index 0000000..5111d05 --- /dev/null +++ b/naja/scenes/dummygame.py @@ -0,0 +1,40 @@ +""" +Dummy scene that overlays a static rendering of a a game scene +""" + +import pygame.locals as pgl +import pygame + +from naja.constants import KEYS, PALETTE, SCREEN +from naja.events import SceneChangeEvent, LoadGameEvent +from naja.sound import sound +from naja.scenes.scene import Scene +from naja.scenes.game import GameScene +from naja.gamestate import GameState +from naja.widgets.image_box import PreRenderedImageBox +from naja.widgets.text import TextWidget, TextBoxWidget + + +class DummyGameScene(Scene): + + def __init__(self, state=None): + super(DummyGameScene, self).__init__(state) + if not state: + game_state = GameState.new(max_health=4, wins_required=4) + else: + game_state = state + game = GameScene(game_state, play_sound=False) + game_surface = pygame.surface.Surface(SCREEN) + game.render(game_surface) + # Force tiles past the animation stage + game.board_widget.force_skip_animation() + game.render(game_surface) + self.add(PreRenderedImageBox((0, 0), game_surface)) + + def handle_scene_event(self, ev): + from naja.scenes.menu import MenuScene + if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT: + # drop current state + LoadGameEvent.post(None) + SceneChangeEvent.post(MenuScene) + return