From: David Sharpe Date: Sun, 11 May 2014 16:59:26 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://ctpug.org.za/naja X-Git-Tag: 0.1~410 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=380c2dd6953b2f0cd06de6a4dd6a30f61121c7a9;hp=acfcd6aadbcc6c4ba91b4071fc70cb23a460987c;p=naja.git Merge branch 'master' of git+ssh://ctpug.org.za/naja --- 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 84bf9d0..f17f9c2 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..96e5505 --- /dev/null +++ b/naja/gamestate.py @@ -0,0 +1,25 @@ +""" +The current game state. +""" + +from .constants import BITS +from .gameboard import GameBoard +from .player import Player + + +class GameState(object): + """ + Naja game state. + """ + + INITIAL_BITS = ( + BITS.NORTH | BITS.SOUTH | + BITS.EAST | BITS.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)