DIRECTION_BITS = AttrDict((k, v) for k, v in BITS.items() if v < 4)
CONDITION_BITS = AttrDict((k, v) for k, v in BITS.items() if v >= 4)
+# Game size constants
TILE_SIZE = (96, 96)
+BOARD_SIZE = (5 * TILE_SIZE[0], 5 * TILE_SIZE[1])
+BIT_SIZE = (5 * TILE_SIZE[0], (SCREEN[1] - 5 * TILE_SIZE[1]) // 2)
+INFO_SIZE = (SCREEN[0] - 5 * TILE_SIZE[0], SCREEN[1])
Widget that holds the game tiles.
"""
+from naja.constants import BOARD_SIZE, TILE_SIZE
+
from .base import Widget
+from .tile import TileWidget
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 __init__(self, pos, tiles=None):
+ super(BoardWidget, self).__init__(pos, BOARD_SIZE)
+ # FIXME: Placeholder logic
+ self._tiles = []
+ for y in range(0, 5):
+ for x in range(0, 5):
+ tile_pos = (pos[0] + x * TILE_SIZE[0],
+ pos[1] + y * TILE_SIZE[1])
+ self._tiles.append(TileWidget(tile_pos, None))
def prepare(self):
- pass
+ for tile in self._tiles:
+ tile.prepare()
+ self.size = BOARD_SIZE
def draw(self, surface):
- surface.blit(self.surface, self.rect)
+ for tile in self._tiles:
+ tile.draw(surface)
Widget that holds the games's bits.
"""
+from naja.constants import BIT_SIZE
+
from .base import Widget
Widget which holds the game's bits.
"""
def __init__(self, pos, image=None):
- super(GameBitsWidget, self).__init__(pos, (96, 96))
+ super(GameBitsWidget, self).__init__(pos, BIT_SIZE)
def prepare(self):
pass
def draw(self, surface):
- surface.blit(self.surface, self.rect)
+ pass
+ #surface.blit(self.surface, self.rect)
Widget for the game board information area.
"""
+from naja.constants import INFO_SIZE
+
from .base import Widget
Widget for the game board information area.
"""
def __init__(self, pos, image=None):
- super(InfoAreaWidget, self).__init__(pos, (96, 96))
+ super(InfoAreaWidget, self).__init__(pos, INFO_SIZE)
def prepare(self):
pass
def draw(self, surface):
- surface.blit(self.surface, self.rect)
+ pass
+ #surface.blit(self.surface, self.rect)
"""
from .base import Widget
+from naja.constants import BIT_SIZE
class PlayerBitsWidget(Widget):
Widget which holds the player's bits.
"""
def __init__(self, pos, image=None):
- super(PlayerBitsWidget, self).__init__(pos, (96, 96))
+ super(PlayerBitsWidget, self).__init__(pos, BIT_SIZE)
def prepare(self):
pass
def draw(self, surface):
- surface.blit(self.surface, self.rect)
+ pass
+ #surface.blit(self.surface, self.rect)
from naja.constants import TILE_SIZE
-from naja.widgets.base import Widget
from naja.resources import resources
+from .base import Widget
+
# These will probably need to go away when we have images
import pygame
import pygame.locals as pgl
def prepare(self):
# Placeholder logic - just draw the outline of a square
- self.surface = pygame.surface.Surface(self.size)
+ self.surface = pygame.surface.Surface(TILE_SIZE)
pygame.draw.lines(self.surface, pgl.color.THECOLORS['yellow'],
True, [(1, 1), (1, 95), (95, 95), (95, 1)], 2)
self.surface.convert_alpha(pygame.display.get_surface())