projects
/
tabakrolletjie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ab39c18
)
Use images to draw Boyd
author
Neil
<neil@dip.sun.ac.za>
Tue, 6 Sep 2016 20:05:34 +0000
(22:05 +0200)
committer
Neil
<neil@dip.sun.ac.za>
Tue, 6 Sep 2016 20:05:51 +0000
(22:05 +0200)
tabakrolletjie/enemies.py
patch
|
blob
|
history
diff --git
a/tabakrolletjie/enemies.py
b/tabakrolletjie/enemies.py
index 830ef731bfd102fecaf82443f81cd6f3001750a0..7b26fed214ebb600a5366aa4d40c85b1eb6edcee 100644
(file)
--- a/
tabakrolletjie/enemies.py
+++ b/
tabakrolletjie/enemies.py
@@
-1,5
+1,7
@@
# Boyd, the friendly, misunderstood turnip loving, light hating space mould
# Boyd, the friendly, misunderstood turnip loving, light hating space mould
+import random
+
import pymunk
import pymunk.pygame_util
import pygame.draw
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
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,
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:
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):
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
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)
choice = random.randint(0, 4)
if choice == 0:
pos = self.position + (0, 24)