import random
from pgzero.clock import each_tick
from pgzero.loaders import images
+from pygame.constants import BLEND_RGBA_MULT
from .actors.surf import SurfActor
+ROACH_COLORS = {
+ "blue": (0, 0, 255, 255),
+ "green": (0, 255, 0, 255),
+ "purple": (255, 0, 255, 255),
+}
+
class RoachActor(SurfActor):
def __init__(self, frames):
self.suffix = suffix
self.frames = 4
- def assemble_frame(self, i, roach_data):
+ def roach_color(self, roach_data):
+ return random.choice(list(ROACH_COLORS.values()))
+
+ def assemble_frame(self, i, color, roach_data):
roach = images.load("roach%s/roach_%d" % (self.suffix, i + 1))
eyes = images.load("roach%s/eyes_%d" % (self.suffix, i + 1))
+ roach = roach.copy()
+ roach.fill(color, None, BLEND_RGBA_MULT)
roach.blit(eyes, (0, 0))
return roach
def assemble(self, roach_data):
+ color = self.roach_color(roach_data)
frames = [
- self.assemble_frame(i, roach_data) for i in range(self.frames)]
+ self.assemble_frame(i, color, roach_data)
+ for i in range(self.frames)]
return RoachActor(frames)