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.animation = TILE_SIZE[0]
def prepare(self):
# Draw background
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)
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)