From 830d14c2483c280292d38794e9e67b373b56a09c Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 6 Sep 2016 22:05:34 +0200 Subject: [PATCH] Use images to draw Boyd --- tabakrolletjie/enemies.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tabakrolletjie/enemies.py b/tabakrolletjie/enemies.py index 830ef73..7b26fed 100644 --- a/tabakrolletjie/enemies.py +++ b/tabakrolletjie/enemies.py @@ -1,5 +1,7 @@ # Boyd, the friendly, misunderstood turnip loving, light hating space mould +import random + import pymunk import pymunk.pygame_util import pygame.draw @@ -9,6 +11,7 @@ import pygame.display import pygame.locals as pgl from .constants import SCREEN_SIZE, MOULD_CATEGORY, OBSTACLE_CATEGORY +from .loader import loader MOULD_FILTER = pymunk.ShapeFilter( mask=MOULD_CATEGORY | OBSTACLE_CATEGORY, @@ -30,11 +33,9 @@ class Mould(pymunk.Body): def get_image(self): if not self._img: - img = pygame.surface.Surface((32, 32)) - img.convert_alpha(pygame.display.get_surface()) - img.fill((0, 0, 0, 0)) - pygame.draw.circle(img, (255, 255, 255, 255), (16, 16), 16) - self._img = img + name = random.choice( + ('mouldA.png', 'mouldB.png', 'mouldC.png')) + self._img = loader.load_image("32", name) return self._img def tick(self, gamestate, space, moulds): @@ -46,7 +47,6 @@ class Mould(pymunk.Body): if (self._age % 15) == 0 and len(moulds) < 1000: # Spawn a new child, if we can spawn = True - import random choice = random.randint(0, 4) if choice == 0: pos = self.position + (0, 24) -- 2.34.1