Render bit pattern markers on tile widgets
[naja.git] / naja / widgets / board.py
index c791a57610231ccd477e14e30ebf6b4d993f2ba9..c5eef2ac50ae00784e120fc2a70fc180fa5a7733 100644 (file)
@@ -2,18 +2,30 @@
 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)