From: adrianna Date: Fri, 9 Sep 2016 15:17:27 +0000 (+0200) Subject: pseudo-random turnip rotation X-Git-Tag: tabakrolletjie-v1.0.0~167 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=019cf4fad33ecb08e4154aa8fd8561f882036a5e;p=tabakrolletjie.git pseudo-random turnip rotation --- diff --git a/tabakrolletjie/turnip.py b/tabakrolletjie/turnip.py index 5f4e8c5..f40478a 100644 --- a/tabakrolletjie/turnip.py +++ b/tabakrolletjie/turnip.py @@ -3,6 +3,7 @@ import pymunk import pymunk.pygame_util import pygame.display +import pygame.transform from .loader import loader from .constants import TURNIP_CATEGORY, LIGHT_CATEGORY @@ -23,6 +24,7 @@ class Turnip(object): self._age = kwargs.get('age', 0) self._pos = kwargs.get('pos', (0, 0)) space = kwargs.get('space', None) + self._rotation = 90 * (hash(self._pos) % 4) self._update_image() self.eaten = False # Flag for boyd self._body = pymunk.Body(0, 0, pymunk.Body.STATIC) @@ -38,6 +40,7 @@ class Turnip(object): def _update_image(self): self._image = loader.load_image('32', 'turnip%d.png' % (self._age + 1)) + self._image = pygame.transform.rotate(self._image, self._rotation) def render(self, surface): surface.blit(self._image, self._pos, None)