X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Froaches.py;h=b708a88b9b0219f65bee7656b924362113cca6a8;hb=9d3fee60d4fb75d183d6db5af8468c2d9dbf9e85;hp=c844b5277c404c41c4448239d58daa564fecb570;hpb=3266c4cb2a620fa01e1b39056acfed203425c000;p=koperkapel.git diff --git a/koperkapel/roaches.py b/koperkapel/roaches.py index c844b52..b708a88 100644 --- a/koperkapel/roaches.py +++ b/koperkapel/roaches.py @@ -5,6 +5,32 @@ from pygame.constants import BLEND_RGBA_MULT from .actors.animsurf import AnimatedSurfActor from .serums import roach_serum_color +NAMES = [ + "roupert", + "roachel", + "roeginald", + "roichard", + "rory", + "roalph", + "roabia", + "roafi", + "roaman", + "roemus", + "roadley", + "roanaell", + "roashwan", + "roashid", + "roaphael", + "roenfield", + "roani", + "roaya", + "roaza", + "robekka", + "rogan", + "roiana", + "roberta", +] + def roach_by_name(world, roach_name): roaches = [r for r in world.roaches if r.name == roach_name] @@ -13,6 +39,26 @@ def roach_by_name(world, roach_name): return roaches[0] +def next_roach_name(world): + roach_names = [x['name'] for x in world.roaches] + for cand in NAMES: + if cand not in roach_names: + return cand + + +def build_roach(world, name=None, health=5, **kw): + if name is None: + name = next_roach_name(world) + if name is None: + return + roach = { + "name": name, + "health": health, + } + roach.update(kw) + return roach + + class WorldRoach(object): """A roach proxy with no properties for display on the game level.""" @@ -28,18 +74,25 @@ class RoachFactory: self.suffix = suffix self.frames = 4 - def assemble_frame(self, i, color, roach_data): + def assemble_frame(self, i, color, roach_data, weapon=None): roach = images.load("roach%s/roach_%d" % (self.suffix, i + 1)) eyes = images.load("roach%s/eyes_%d" % (self.suffix, i + 1)) - frame = roach.copy() - frame.fill(color, None, BLEND_RGBA_MULT) + if weapon is None: + frame = roach.copy() + frame.fill(color, None, BLEND_RGBA_MULT) + else: + frame = weapon.surf.copy() + roach = roach.copy() + roach.fill(color, None, BLEND_RGBA_MULT) + frame.blit(roach, (0, 0)) frame.blit(eyes, (0, 0)) return frame - def assemble(self, roach_data): + def assemble(self, roach_data, weapon=None): color = roach_serum_color(roach_data) + frames = [] frames = [ - self.assemble_frame(i, color, roach_data) + self.assemble_frame(i, color, roach_data, weapon) for i in range(self.frames)] return AnimatedSurfActor(frames)