Add widgets and skeleton for game scene.
authorSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 16:31:36 +0000 (18:31 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 16:32:19 +0000 (18:32 +0200)
naja/scenes/game.py
naja/widgets/board.py [new file with mode: 0644]
naja/widgets/game_bits.py [new file with mode: 0644]
naja/widgets/info_area.py [new file with mode: 0644]
naja/widgets/player_bits.py [new file with mode: 0644]

index 16be11ec8cbca0a3857aab6c5291566b24af66c0..b96120bd7690e307504895127c07d6423f588941 100644 (file)
@@ -2,10 +2,32 @@
 Gameboard scene.
 """
 
+import pygame.locals as pgl
+
 from .scene import Scene
+from .menu import MenuScene
+
+from naja.widgets.board import BoardWidget
+from naja.widgets.player_bits import PlayerBitsWidget
+from naja.widgets.game_bits import GameBitsWidget
+from naja.widgets.info_area import InfoAreaWidget
+
+from naja.events import SceneChangeEvent
 
 
 class GameScene(Scene):
     """
     Gameboard scene.
     """
+
+    def __init__(self):
+        super(GameScene, self).__init__()
+        self.widgets.append(PlayerBitsWidget())
+        self.widgets.append(BoardWidget())
+        self.widgets.append(GameBitsWidget())
+        self.widgets.append(InfoAreaWidget())
+
+    def handle_event(self, ev):
+        if ev.type == pgl.KEYUP and ev.key in (pgl.K_q, pgl.K_ESCAPE):
+            SceneChangeEvent.post(scene=MenuScene())
+            return
diff --git a/naja/widgets/board.py b/naja/widgets/board.py
new file mode 100644 (file)
index 0000000..c791a57
--- /dev/null
@@ -0,0 +1,19 @@
+"""
+Widget that holds the game tiles.
+"""
+
+from .base import Widget
+
+
+class BoardWidget(Widget):
+    """
+    Widget which holds all the tiles that make up the gameboard.
+    """
+    def __init__(self, pos, image=None):
+        super(BoardWidget, self).__init__(pos, (96, 96))
+
+    def prepare(self):
+        pass
+
+    def draw(self, surface):
+        surface.blit(self.surface, self.rect)
diff --git a/naja/widgets/game_bits.py b/naja/widgets/game_bits.py
new file mode 100644 (file)
index 0000000..54fa683
--- /dev/null
@@ -0,0 +1,19 @@
+"""
+Widget that holds the games's bits.
+"""
+
+from .base import Widget
+
+
+class GameBitsWidget(Widget):
+    """
+    Widget which holds the game's bits.
+    """
+    def __init__(self, pos, image=None):
+        super(GameBitsWidget, self).__init__(pos, (96, 96))
+
+    def prepare(self):
+        pass
+
+    def draw(self, surface):
+        surface.blit(self.surface, self.rect)
diff --git a/naja/widgets/info_area.py b/naja/widgets/info_area.py
new file mode 100644 (file)
index 0000000..2f93311
--- /dev/null
@@ -0,0 +1,19 @@
+"""
+Widget for the game board information area.
+"""
+
+from .base import Widget
+
+
+class InfoAreaWidget(Widget):
+    """
+    Widget for the game board information area.
+    """
+    def __init__(self, pos, image=None):
+        super(InfoAreaWidget, self).__init__(pos, (96, 96))
+
+    def prepare(self):
+        pass
+
+    def draw(self, surface):
+        surface.blit(self.surface, self.rect)
diff --git a/naja/widgets/player_bits.py b/naja/widgets/player_bits.py
new file mode 100644 (file)
index 0000000..e82f173
--- /dev/null
@@ -0,0 +1,19 @@
+"""
+Widget that holds the player's bits.
+"""
+
+from .base import Widget
+
+
+class PlayerBitsWidget(Widget):
+    """
+    Widget which holds the player's bits.
+    """
+    def __init__(self, pos, image=None):
+        super(PlayerBitsWidget, self).__init__(pos, (96, 96))
+
+    def prepare(self):
+        pass
+
+    def draw(self, surface):
+        surface.blit(self.surface, self.rect)