Add tiles to the board. Skip draw for other game scene widgets for now
[naja.git] / naja / widgets / board.py
index c791a57610231ccd477e14e30ebf6b4d993f2ba9..1f59f015f1cb1eacd5bb68de952986942c160b3c 100644 (file)
@@ -2,18 +2,31 @@
 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)