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 "health": (255, 0, 0, 255), # red
23 "none": (170, 68, 0, 255), # brown
27 def roach_serum_color(roach):
28 for serum_name in SERUMS:
29 if getattr(roach, serum_name):
30 return SERUM_OVERLAY_COLORS[serum_name]
31 return SERUM_OVERLAY_COLORS["none"]
34 def roach_is_serumless(roach):
35 for serum_name in SERUMS:
36 if getattr(roach, serum_name):
42 def __init__(self, suffix):
45 def assemble_icon(self, name, color=None):
48 serum_icon = images.load(safepath("serum%s/%s") % (
49 self.suffix, SERUM_TILENAME_MAP[name],))
50 frame = serum_icon.copy()
51 frame.fill(SERUM_OVERLAY_COLORS[color], None, BLEND_RGBA_MULT)
54 def assemble(self, name):
56 puddle = images.load(safepath("serum%s/serum") % (self.suffix,))
57 puddle = rotate(puddle, 90 * random.randint(0, 3))
58 serum_icon = images.load(safepath("serum%s/%s") % (
59 self.suffix, SERUM_TILENAME_MAP[name],))
61 frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)
62 frame.blit(serum_icon, (0, 0))
63 return SurfActor(frame)
66 default_serums = SerumFactory("")
67 big_serums = SerumFactory("_big")