Add tiles to the board. Skip draw for other game scene widgets for now
[naja.git] / naja / widgets / board.py
1 """
2 Widget that holds the game tiles.
3 """
4
5 from naja.constants import BOARD_SIZE, TILE_SIZE
6
7 from .base import Widget
8 from .tile import TileWidget
9
10
11 class BoardWidget(Widget):
12     """
13     Widget which holds all the tiles that make up the gameboard.
14     """
15     def __init__(self, pos, tiles=None):
16         super(BoardWidget, self).__init__(pos, BOARD_SIZE)
17         # FIXME: Placeholder logic
18         self._tiles = []
19         for y in range(0, 5):
20             for x in range(0, 5):
21                 tile_pos = (pos[0] + x * TILE_SIZE[0],
22                             pos[1] + y * TILE_SIZE[1])
23                 self._tiles.append(TileWidget(tile_pos, None))
24
25     def prepare(self):
26         for tile in self._tiles:
27             tile.prepare()
28         self.size = BOARD_SIZE
29
30     def draw(self, surface):
31         for tile in self._tiles:
32             tile.draw(surface)