Hack anchor support for rotation
authorNeil <neil@dip.sun.ac.za>
Sat, 5 Mar 2016 13:23:50 +0000 (15:23 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 5 Mar 2016 13:24:27 +0000 (15:24 +0200)
koperkapel/actors/orientatedsurf.py

index 6db857035c518ec8ed84e08c104a2dc8bb8dc976..720bb204cdb5a69e28a2ce482acffc1cfe1d0ab9 100644 (file)
@@ -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):