X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Factors%2Forientatedsurf.py;h=ae79c43007d78a4ca28c19de52a352a53fd86655;hb=76f34080ddc9feafd188c83c24eee5c71af59a10;hp=5c8df654b8b7f827b0fab58ad01d34aefc0f8c61;hpb=81a5f79d900e83c7371c9650a4ae7400ed2e6c8c;p=koperkapel.git diff --git a/koperkapel/actors/orientatedsurf.py b/koperkapel/actors/orientatedsurf.py index 5c8df65..ae79c43 100644 --- a/koperkapel/actors/orientatedsurf.py +++ b/koperkapel/actors/orientatedsurf.py @@ -4,9 +4,12 @@ from pygame.transform import rotate from pgzero.actor import POS_TOPLEFT, ANCHOR_CENTER from .surf import SurfActor +from ..constants import TILE_SIZE + class OrientatedSurfActor(SurfActor): - def __init__(self, surf, pos=POS_TOPLEFT, anchor=ANCHOR_CENTER, angle=0, **kwargs): + def __init__(self, surf, pos=POS_TOPLEFT, anchor=ANCHOR_CENTER, angle=0, + **kwargs): self._handle_unexpected_kwargs(kwargs) self._angle = angle @@ -20,6 +23,9 @@ class OrientatedSurfActor(SurfActor): @angle.setter def angle(self, angle): + cur_anchor = self._anchor_value + if angle not in (self._angle, self._angle + 180, self._angle - 180): + self._anchor_value = (cur_anchor[1], cur_anchor[0]) self._angle = angle self._surf = self._orig_surf = rotate(self._base_surf, angle)