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_icon(self, name):
46 serum_icon = images.load(safepath("serum%s/%s") % (
47 self.suffix, SERUM_TILENAME_MAP[name],))
48 frame = serum_icon.copy()
49 frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)
52 def assemble(self, name):
54 puddle = images.load(safepath("serum%s/serum") % (self.suffix,))
55 puddle = rotate(puddle, 90 * random.randint(0, 3))
56 serum_icon = images.load(safepath("serum%s/%s") % (
57 self.suffix, SERUM_TILENAME_MAP[name],))
59 frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)
60 frame.blit(serum_icon, (0, 0))
61 return SurfActor(frame)
64 default_serums = SerumFactory("")
65 big_serums = SerumFactory("_big")