1 """ Tools for creating serum actors. """
4 from pgzero.loaders import images
5 from pygame.constants import BLEND_RGBA_MULT
6 from pygame.transform import rotate
7 from .actors.surf import SurfActor
8 from .util import safepath
10 SERUMS = ["smart", "fast", "strong"]
12 SERUM_TILENAME_MAP = {
13 "smart": "intelligence",
18 SERUM_OVERLAY_COLORS = {
19 "smart": (0, 0, 255, 255), # blue
20 "fast": (0, 255, 0, 255), # green
21 "strong": (255, 0, 255, 255), # purple
22 "none": (170, 68, 0, 255), # brown
26 def roach_serum_color(roach):
27 for serum_name in SERUMS:
28 if getattr(roach, serum_name):
29 return SERUM_OVERLAY_COLORS[serum_name]
30 return SERUM_OVERLAY_COLORS["none"]
33 def roach_is_serumless(roach):
34 for serum_name in SERUMS:
35 if getattr(roach, serum_name):
41 def __init__(self, suffix):
44 def assemble(self, name):
46 puddle = images.load(safepath("serum%s/serum") % (self.suffix,))
47 puddle = rotate(puddle, 90 * random.randint(0, 3))
48 serum_icon = images.load(safepath("serum%s/%s") % (
49 self.suffix, SERUM_TILENAME_MAP[name],))
51 frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)
52 frame.blit(serum_icon, (0, 0))
53 return SurfActor(frame)
56 default_serums = SerumFactory("")
57 big_serums = SerumFactory("_big")