changeset 347:b150ed7188a2

Show the size of the spellcard life.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Jul 2012 00:53:16 +0200
parents 862011266f2c
children 685b782a4da4
files pytouhou/game/text.py pytouhou/games/eosd.py pytouhou/vm/eclrunner.py
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/text.py
+++ b/pytouhou/game/text.py
@@ -151,7 +151,7 @@ class Counter(GlyphCollection):
 
 
 class Gauge(object):
-    def __init__(self, pos, anm_wrapper, max_length=280, maximum=1, value=0.):
+    def __init__(self, pos, anm_wrapper, max_length=280, maximum=1, value=0):
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(anm_wrapper, 21, self.sprite)
         self.anmrunner.run_frame()
@@ -172,6 +172,11 @@ class Gauge(object):
 
 
     def update(self):
+        #XXX
+        if self.value == 0:
+            self.sprite.visible = False
+        else:
+            self.sprite.visible = True
         if self.anmrunner and not self.anmrunner.run_frame():
             self.anmrunner = None
 
--- a/pytouhou/games/eosd.py
+++ b/pytouhou/games/eosd.py
@@ -139,6 +139,7 @@ class EoSDInterface(object):
         self.boss_items = [
             Effect((0, 0), 19, front), # Enemy
             Gauge((100, 24), front), # Gauge
+            Gauge((100, 24), front), # Spellcard gauge
         ]
         for item in self.boss_items:
             item.sprite.allow_dest_offset = True #XXX
@@ -146,6 +147,11 @@ class EoSDInterface(object):
 
     def set_boss_life(self):
         self.boss_items[1].maximum = self.game.boss._enemy.life
+        self.boss_items[2].maximum = self.game.boss._enemy.life
+
+
+    def set_spell_life(self):
+        self.boss_items[2].set_value(self.game.boss._enemy.low_life_trigger)
 
 
     def update(self):
@@ -169,6 +175,11 @@ class EoSDInterface(object):
             life_gauge = self.boss_items[1]
             life_gauge.set_value(boss.life)
 
+            spell_gauge = self.boss_items[2]
+            spell_gauge.sprite.color = (255, 192, 192)
+            if boss.life < spell_gauge.value:
+                spell_gauge.set_value(boss.life)
+
             for item in self.boss_items:
                 item.update()
 
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -875,6 +875,7 @@ class ECLRunner(object):
         # During those frames, the ECL doesn't seem to be executed.
         # However, the ECL isn't directly paused by this instruction itself.
         self._enemy.low_life_trigger = value
+        self._game.interface.set_spell_life()
 
 
     @instruction(114)