GameState.
authorSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 16:57:35 +0000 (18:57 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 16:57:35 +0000 (18:57 +0200)
naja/__main__.py
naja/engine.py
naja/gamestate.py [new file with mode: 0644]

index 1ac982e35aa015bd94b6ef8f272d4782e093dbd3..98ee298e62ad0c12df4ce94636077fce3a15ebb2 100644 (file)
@@ -8,6 +8,7 @@ from naja.engine import Engine
 from naja.sound import sound
 from naja.options import parse_args
 from naja.scenes.menu import MenuScene
+from naja.gamestate import GameState
 
 
 def main():
@@ -21,8 +22,9 @@ def main():
     sound.init()
 
     screen = pygame.display.get_surface()
+    state = GameState()
     scene = MenuScene()
-    engine = Engine(screen, scene)
+    engine = Engine(screen, scene, state)
     engine.run()
 
 
index a8e01460c8b345336f874f0c5fc104b7bda26289..32c139f8a56f17427b0a426bdb3b1e2fe3ec338d 100644 (file)
@@ -6,9 +6,10 @@ from naja.events import SceneChangeEvent, QuitGameEvent
 
 
 class Engine(object):
-    def __init__(self, surface, scene):
+    def __init__(self, surface, scene, state):
         self._surface = surface
         self._scene = scene
+        self._state = state
 
     def run(self):
         clock = pygame.time.Clock()
diff --git a/naja/gamestate.py b/naja/gamestate.py
new file mode 100644 (file)
index 0000000..9dca030
--- /dev/null
@@ -0,0 +1,22 @@
+"""
+The current game state.
+"""
+
+from .constants import NORTH, SOUTH, EAST, WEST
+from .gameboard import GameBoard
+from .player import Player
+
+
+class GameState(object):
+    """
+    Naja game state.
+    """
+
+    INITIAL_BITS = NORTH | SOUTH | EAST | WEST
+    MAX_HEALTH = 4
+    WINS_REQUIRED = 4
+
+    def __init__(self):
+        self.player = Player(self.INITIAL_BITS, (0, 0))
+        self.gameboard = GameBoard(
+            self.player, self.MAX_HEALTH, self.WINS_REQUIRED)