Very statis hud.
[koperkapel.git] / koperkapel / serums.py
index c2a52bba6ff0e10525597d2b1a1760108ef95036..5162180502e36e8c2c126f1da5379f1e5b079049 100644 (file)
@@ -1,8 +1,11 @@
 """ 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"]
 
@@ -27,14 +30,30 @@ def roach_serum_color(roach):
     return SERUM_OVERLAY_COLORS["none"]
 
 
+def roach_is_serumless(roach):
+    for serum_name in SERUMS:
+        if getattr(roach, serum_name):
+            return False
+    return True
+
+
 class SerumFactory:
     def __init__(self, suffix):
         self.suffix = suffix
 
+    def assemble_icon(self, name):
+        assert name in SERUMS
+        serum_icon = images.load(safepath("serum%s/%s") % (
+            self.suffix, SERUM_TILENAME_MAP[name],))
+        frame = serum_icon.copy()
+        frame.fill(SERUM_OVERLAY_COLORS[name], 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)