Add a dummygame scene
authorNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 21:37:10 +0000 (23:37 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 17 May 2014 21:37:20 +0000 (23:37 +0200)
naja/scenes/dummygame.py [new file with mode: 0644]

diff --git a/naja/scenes/dummygame.py b/naja/scenes/dummygame.py
new file mode 100644 (file)
index 0000000..5111d05
--- /dev/null
@@ -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