From 78a001f6b445795f347d1ae7399d8f3b4072f779 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 11 May 2014 18:57:35 +0200 Subject: [PATCH] GameState. --- naja/__main__.py | 4 +++- naja/engine.py | 3 ++- naja/gamestate.py | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 naja/gamestate.py diff --git a/naja/__main__.py b/naja/__main__.py index 1ac982e..98ee298 100644 --- a/naja/__main__.py +++ b/naja/__main__.py @@ -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() diff --git a/naja/engine.py b/naja/engine.py index a8e0146..32c139f 100644 --- a/naja/engine.py +++ b/naja/engine.py @@ -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 index 0000000..9dca030 --- /dev/null +++ b/naja/gamestate.py @@ -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) -- 2.34.1