""" Tools for creating serum actors. """
+import random
from pgzero.loaders import images
from pygame.constants import BLEND_RGBA_MULT
+from pygame.transform import rotate
from .actors.surf import SurfActor
+from .util import safepath
SERUMS = ["smart", "fast", "strong"]
"smart": (0, 0, 255, 255), # blue
"fast": (0, 255, 0, 255), # green
"strong": (255, 0, 255, 255), # purple
+ "health": (255, 0, 0, 255), # red
"none": (170, 68, 0, 255), # brown
}
def __init__(self, suffix):
self.suffix = suffix
+ def assemble_icon(self, name, color=None):
+ assert name in SERUMS
+ color = color or name
+ serum_icon = images.load(safepath("serum%s/%s") % (
+ self.suffix, SERUM_TILENAME_MAP[name],))
+ frame = serum_icon.copy()
+ frame.fill(SERUM_OVERLAY_COLORS[color], None, BLEND_RGBA_MULT)
+ return frame
+
def assemble(self, name):
assert name in SERUMS
- puddle = images.load("serum%s/serum" % (self.suffix,))
- serum_icon = images.load("serum%s/%s" % (
+ puddle = images.load(safepath("serum%s/serum") % (self.suffix,))
+ puddle = rotate(puddle, 90 * random.randint(0, 3))
+ serum_icon = images.load(safepath("serum%s/%s") % (
self.suffix, SERUM_TILENAME_MAP[name],))
frame = puddle.copy()
frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)