From: Simon Cross Date: Fri, 4 Mar 2016 22:42:41 +0000 (+0200) Subject: Serum assembly. X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=9b4ed6a78343aca0bdcfb347730142458c911e3f;p=koperkapel.git Serum assembly. --- 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")