From 9b4ed6a78343aca0bdcfb347730142458c911e3f Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 00:42:41 +0200 Subject: [PATCH] Serum assembly. --- koperkapel/serums.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/koperkapel/serums.py b/koperkapel/serums.py index 951d002..c2a52bb 100644 --- a/koperkapel/serums.py +++ b/koperkapel/serums.py @@ -1,8 +1,17 @@ """ Tools for creating serum actors. """ +from pgzero.loaders import images +from pygame.constants import BLEND_RGBA_MULT +from .actors.surf import SurfActor SERUMS = ["smart", "fast", "strong"] +SERUM_TILENAME_MAP = { + "smart": "intelligence", + "fast": "speed", + "strong": "strength", +} + SERUM_OVERLAY_COLORS = { "smart": (0, 0, 255, 255), # blue "fast": (0, 255, 0, 255), # green @@ -16,3 +25,22 @@ def roach_serum_color(roach): if getattr(roach, serum_name): return SERUM_OVERLAY_COLORS[serum_name] return SERUM_OVERLAY_COLORS["none"] + + +class SerumFactory: + def __init__(self, suffix): + self.suffix = suffix + + def assemble(self, name): + assert name in SERUMS + puddle = images.load("serum%s/serum" % (self.suffix,)) + serum_icon = images.load("serum%s/%s" % ( + self.suffix, SERUM_TILENAME_MAP[name],)) + frame = puddle.copy() + frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT) + frame.blit(serum_icon, (0, 0)) + return SurfActor(frame) + + +default_serums = SerumFactory("") +big_serums = SerumFactory("_big") -- 2.34.1