From: Simon Cross Date: Sat, 5 Mar 2016 19:42:25 +0000 (+0200) Subject: Pull SelectableSurfActor out of vehicles. X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=b84add9e04e7a5ac7832cb97b0ff83586eb716fb;p=koperkapel.git Pull SelectableSurfActor out of vehicles. --- diff --git a/koperkapel/actors/orientatedsurf.py b/koperkapel/actors/orientatedsurf.py index ae79c43..284ac71 100644 --- a/koperkapel/actors/orientatedsurf.py +++ b/koperkapel/actors/orientatedsurf.py @@ -39,3 +39,20 @@ class OrientatedSurfActor(SurfActor): self._base_surf = surf self._orig_surf = self._surf = rotate(surf, self._angle) self._update_pos() + + +class SelectableSurfActor(OrientatedSurfActor): + def __init__(self, seat, selected_seat): + self._selected = False + self._seat = seat + self._selected_seat = selected_seat + super().__init__(surf=self._seat, angle=0) + + @property + def selected(self): + return self._selected + + @selected.setter + def selected(self, value): + self._selected = value + self.surf = self._selected_seat if value else self._seat diff --git a/koperkapel/vehicles/base.py b/koperkapel/vehicles/base.py index 27e1b24..ba21bbe 100644 --- a/koperkapel/vehicles/base.py +++ b/koperkapel/vehicles/base.py @@ -5,7 +5,7 @@ import random from itertools import chain, islice, repeat from pygame.constants import BLEND_RGBA_MULT from pgzero.loaders import images -from ..actors.orientatedsurf import OrientatedSurfActor +from ..actors.orientatedsurf import SelectableSurfActor from ..actors.animsurf import AnimatedSurfActor from ..weapons import default_weapons @@ -129,24 +129,7 @@ class Seat: selected_seat = seat.copy() selected_seat.fill( self.vehicle.selected_seat_overlay_color, None, BLEND_RGBA_MULT) - return SeatActor(seat, selected_seat) - - -class SeatActor(OrientatedSurfActor): - def __init__(self, seat, selected_seat): - self._selected = False - self._seat = seat - self._selected_seat = selected_seat - super().__init__(surf=self._seat, angle=0) - - @property - def selected(self): - return self._selected - - @selected.setter - def selected(self, value): - self._selected = value - self.surf = self._selected_seat if value else self._seat + return SelectableSurfActor(seat, selected_seat) def circle_of_seats(n_seats, **kw):