Widget that holds the game tiles.
"""
-from .base import Widget
+from naja.constants import BOARD_SIZE, TILE_SIZE
+from naja.widgets.base import Widget
+from naja.widgets.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, state):
+ 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, state, (x, y)))
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)