projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make chess puzzle level (Kasparov to F3) winnable.
[naja.git]
/
naja
/
widgets
/
board.py
diff --git
a/naja/widgets/board.py
b/naja/widgets/board.py
index b2a93fa8e0baa6a5fffa5cc3ba9b1b62e9ccac7e..f7f8384198f8ae64023ae392bc5a091098152762 100644
(file)
--- 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
"""
import pygame.locals as pgl
-from naja.constants import BOARD_SIZE, TILE_SIZE, KEYS, ACT
-from naja.events import finish_event
+from naja.constants import BOARD_SIZE, TILE_SIZE, KEYS, ACT
, FPS
+from naja.events import
InvalidateTheWorld,
finish_event
from naja.sound import sound
from naja.widgets.base import Widget
from naja.widgets.tile import TileWidget
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):
class BoardWidget(Widget):
@@
-22,6
+23,7
@@
class BoardWidget(Widget):
self.card_pos = state.player.position
self._tiles = []
self.legal = False
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],
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:
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):
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)
for tile in self._tiles:
tile.draw(surface)
@@
-67,6
+71,8
@@
class BoardWidget(Widget):
tile.animation = 0
def handle_event(self, ev):
tile.animation = 0
def handle_event(self, ev):
+ if InvalidateTheWorld.matches(ev):
+ self.flash_light.reset()
if self.state.gameboard.player_mode == ACT:
return super(BoardWidget, self).handle_event(ev)
if ev.type == pgl.KEYDOWN:
if self.state.gameboard.player_mode == ACT:
return super(BoardWidget, self).handle_event(ev)
if ev.type == pgl.KEYDOWN: