X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Fboard.py;h=e6eafa5e8a429468f39fcfe51b70927b68ef0160;hb=0b43a81c2816278ea23e97a41a5cfc7473b4b054;hp=b168c6b35ec3a706ad279285a9a99bf6daa65eea;hpb=85d70adb07711749c5775c3f249d04f462bf97e0;p=naja.git diff --git a/naja/widgets/board.py b/naja/widgets/board.py index b168c6b..e6eafa5 100644 --- a/naja/widgets/board.py +++ b/naja/widgets/board.py @@ -3,12 +3,13 @@ Widget that holds the game tiles. """ import pygame.locals as pgl -from naja.constants import BOARD_SIZE, TILE_SIZE, KEYS, ACT +from naja.constants import BOARD_SIZE, TILE_SIZE, KEYS, ACT, FPS from naja.events import finish_event from naja.sound import sound from naja.widgets.base import Widget from naja.widgets.tile import TileWidget +from naja.utils import Flashlight class BoardWidget(Widget): @@ -19,9 +20,10 @@ class BoardWidget(Widget): super(BoardWidget, self).__init__(pos, BOARD_SIZE) self.info = info self.state = state - self.card_pos = (2, 2) + self.card_pos = state.player.position self._tiles = [] self.legal = False + self.flash_light = Flashlight(FPS // 2) for y in range(0, 5): for x in range(0, 5): tile_pos = (pos[0] + x * TILE_SIZE[0], @@ -30,13 +32,15 @@ class BoardWidget(Widget): def prepare(self): for tile in self._tiles: - tile.set_highlight(self.card_pos) + tile.set_highlight(self.card_pos, self.flash_light.on) tile.prepare() self.size = BOARD_SIZE if self.state.gameboard.player_mode == ACT: self.card_pos = self.state.player.position def draw(self, surface): + if self.flash_light.tick(): + self.prepare() for tile in self._tiles: tile.draw(surface) @@ -62,6 +66,10 @@ class BoardWidget(Widget): idx = 0 self.update_card_pos(moves[idx]) + def force_skip_animation(self): + for tile in self._tiles: + tile.animation = 0 + def handle_event(self, ev): if self.state.gameboard.player_mode == ACT: return super(BoardWidget, self).handle_event(ev)