From: Neil Date: Sat, 5 Mar 2016 13:23:50 +0000 (+0200) Subject: Hack anchor support for rotation X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=2086ea379583fdd433e7f9c5c980d82ae65cded7;p=koperkapel.git Hack anchor support for rotation --- diff --git a/koperkapel/actors/orientatedsurf.py b/koperkapel/actors/orientatedsurf.py index 6db8570..720bb20 100644 --- a/koperkapel/actors/orientatedsurf.py +++ b/koperkapel/actors/orientatedsurf.py @@ -4,6 +4,7 @@ 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): @@ -22,8 +23,12 @@ 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) + print(self.anchor, self.angle) @property def surf(self):