From 019cf4fad33ecb08e4154aa8fd8561f882036a5e Mon Sep 17 00:00:00 2001 From: adrianna Date: Fri, 9 Sep 2016 17:17:27 +0200 Subject: [PATCH] pseudo-random turnip rotation --- tabakrolletjie/turnip.py | 3 +++ 1 file changed, 3 insertions(+) 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) -- 2.34.1