fixed turnip/light positioning bug
[tabakrolletjie.git] / tabakrolletjie / turnip.py
index b1bb5a4571f330027fe0b2ea74491636b60e1560..1e2965885909f2179588e0edc99bc37b7a670338 100644 (file)
@@ -19,6 +19,7 @@ class TurnipInvalidPosition(Exception):
 
 
 class Turnip(object):
+    TURNIP_RADIUS = 24
 
     def __init__(self, **kwargs):
         self._age = kwargs.get('age', 0)
@@ -28,7 +29,7 @@ class Turnip(object):
         self._update_image()
         self.eaten = False  # Flag for boyd
         self._body = pymunk.Body(0, 0, pymunk.Body.STATIC)
-        self._shape = pymunk.Circle(self._body, 24)
+        self._shape = pymunk.Circle(self._body, self.TURNIP_RADIUS)
         self._shape.filter = TURNIP_FILTER
         self._body.position = pymunk.pygame_util.from_pygame(
             self._pos, pygame.display.get_surface())
@@ -43,7 +44,8 @@ class Turnip(object):
         self._image = pygame.transform.rotate(self._image, self._rotation)
 
     def render(self, surface):
-        surface.blit(self._image, self._pos, None)
+        rx, ry = self._pos
+        surface.blit(self._image, (rx - self.TURNIP_RADIUS, ry - self.TURNIP_RADIUS), None)
 
     def serialize(self):
         return {'age': self._age, 'pos': self._pos}