c5eef2ac50ae00784e120fc2a70fc180fa5a7733
[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 from naja.widgets.base import Widget
7 from naja.widgets.tile import TileWidget
8
9
10 class BoardWidget(Widget):
11     """
12     Widget which holds all the tiles that make up the gameboard.
13     """
14     def __init__(self, pos, state):
15         super(BoardWidget, self).__init__(pos, BOARD_SIZE)
16         # FIXME: Placeholder logic
17         self._tiles = []
18         for y in range(0, 5):
19             for x in range(0, 5):
20                 tile_pos = (pos[0] + x * TILE_SIZE[0],
21                             pos[1] + y * TILE_SIZE[1])
22                 self._tiles.append(TileWidget(tile_pos, state, (x, y)))
23
24     def prepare(self):
25         for tile in self._tiles:
26             tile.prepare()
27         self.size = BOARD_SIZE
28
29     def draw(self, surface):
30         for tile in self._tiles:
31             tile.draw(surface)