From 05b45639ab5519bb3379269032d84bca9fb681b3 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 17 May 2014 23:37:10 +0200 Subject: [PATCH] Add a dummygame scene --- naja/scenes/dummygame.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 naja/scenes/dummygame.py 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 -- 2.34.1