1 """ Actor that takes a surface. """
3 from pygame.transform import rotate
4 from pgzero.actor import POS_TOPLEFT, ANCHOR_CENTER
6 from .surf import SurfActor
7 from ..constants import TILE_SIZE
10 class OrientatedSurfActor(SurfActor):
11 def __init__(self, surf, pos=POS_TOPLEFT, anchor=ANCHOR_CENTER, angle=0,
13 self._handle_unexpected_kwargs(kwargs)
16 self._base_surf = surf
17 super().__init__(surf, pos, anchor)
18 self._init_position(pos, anchor, **kwargs)
25 def angle(self, angle):
26 cur_anchor = self._anchor_value
27 if angle not in (self._angle, self._angle + 180, self._angle - 180):
28 self._anchor_value = (cur_anchor[1], cur_anchor[0])
30 self._surf = self._orig_surf = rotate(self._base_surf, angle)
34 """ The original surface displaying the actor. """
35 return self._orig_surf
39 self._base_surf = surf
40 self._orig_surf = self._surf = rotate(surf, self._angle)
44 class SelectableSurfActor(OrientatedSurfActor):
45 def __init__(self, seat, selected_seat):
46 self._selected = False
48 self._selected_seat = selected_seat
49 super().__init__(surf=self._seat, angle=0)
56 def selected(self, value):
57 self._selected = value
58 self.surf = self._selected_seat if value else self._seat