projects
/
naja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7114ea2
)
added animations
author
David Sharpe
<decoydavid@gmail.com>
Sat, 17 May 2014 11:00:36 +0000
(13:00 +0200)
committer
David Sharpe
<decoydavid@gmail.com>
Sat, 17 May 2014 11:05:19 +0000
(13:05 +0200)
naja/widgets/tile.py
patch
|
blob
|
history
diff --git
a/naja/widgets/tile.py
b/naja/widgets/tile.py
index db3ffb48cda8ddf5f5d19593f165ee600af2f733..c9326670251d2988704aa2e35d0a7829048682f9 100644
(file)
--- a/
naja/widgets/tile.py
+++ b/
naja/widgets/tile.py
@@
-25,8
+25,10
@@
class TileWidget(Widget):
def __init__(self, pos, state=None, board_pos=None):
super(TileWidget, self).__init__(pos, TILE_SIZE)
self.state = state
def __init__(self, pos, state=None, board_pos=None):
super(TileWidget, self).__init__(pos, TILE_SIZE)
self.state = state
+ self.current_card = None
self.board_pos = board_pos
self.highlighted = False
self.board_pos = board_pos
self.highlighted = False
+ self.animation = TILE_SIZE[0]
def prepare(self):
# Draw background
def prepare(self):
# Draw background
@@
-55,6
+57,10
@@
class TileWidget(Widget):
self.surface.blit(overlay, (0, 0))
# Look up the required bits on the board location
card = self.state.board_locations[self.board_pos]
self.surface.blit(overlay, (0, 0))
# Look up the required bits on the board location
card = self.state.board_locations[self.board_pos]
+ if card is not self.current_card:
+ self.animation = TILE_SIZE[0]
+ self.current_card = card
+
y_offset = TILE_SIZE[1] - LOCK_HEIGHT * len(card.actions)
for action in card.actions:
y_offset = self._prepare_action(action, y_offset)
y_offset = TILE_SIZE[1] - LOCK_HEIGHT * len(card.actions)
for action in card.actions:
y_offset = self._prepare_action(action, y_offset)
@@
-102,4
+108,12
@@
class TileWidget(Widget):
self.highlighted = True
def draw(self, surface):
self.highlighted = True
def draw(self, surface):
- surface.blit(self.surface, self.pos)
+ scaled_width = self.surface.get_width() - self.animation
+ scaled_height = self.surface.get_height() - self.animation
+ scaled_position = (self.pos[0] + (self.animation / 2),
+ self.pos[1] + (self.animation / 2))
+ if self.animation > 0:
+ self.animation = max(0, self.animation - 4)
+ scaled_surface = pygame.transform.scale(
+ self.surface, (scaled_width, scaled_height))
+ surface.blit(scaled_surface, scaled_position)