From: Simon Cross Date: Sun, 11 May 2014 16:31:36 +0000 (+0200) Subject: Add widgets and skeleton for game scene. X-Git-Tag: 0.1~412^2 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=847d271607652c00e62298a37987aae452719b61;p=naja.git Add widgets and skeleton for game scene. --- diff --git a/naja/scenes/game.py b/naja/scenes/game.py index 16be11e..b96120b 100644 --- a/naja/scenes/game.py +++ b/naja/scenes/game.py @@ -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 index 0000000..c791a57 --- /dev/null +++ b/naja/widgets/board.py @@ -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 index 0000000..54fa683 --- /dev/null +++ b/naja/widgets/game_bits.py @@ -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 index 0000000..2f93311 --- /dev/null +++ b/naja/widgets/info_area.py @@ -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 index 0000000..e82f173 --- /dev/null +++ b/naja/widgets/player_bits.py @@ -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)