comparison pytouhou/game/text.py @ 346:862011266f2c

Add a gauge and use it for the enemy life bar.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Jul 2012 00:38:47 +0200
parents 2c4589370cc6
children b150ed7188a2
comparison
equal deleted inserted replaced
345:2c4589370cc6 346:862011266f2c
147 self.set_length(value) 147 self.set_length(value)
148 self.value = value 148 self.value = value
149 self.changed = True 149 self.changed = True
150 150
151 151
152
153 class Gauge(object):
154 def __init__(self, pos, anm_wrapper, max_length=280, maximum=1, value=0.):
155 self.sprite = Sprite()
156 self.anmrunner = ANMRunner(anm_wrapper, 21, self.sprite)
157 self.anmrunner.run_frame()
158 self.removed = False
159 self.sprite.corner_relative_placement = True #TODO: perhaps not right
160
161 self.x, self.y = pos
162 self.max_length = max_length
163 self.maximum = maximum
164
165 self.set_value(value)
166
167
168 def set_value(self, value):
169 self.value = value
170 self.sprite.width_override = self.max_length * value / self.maximum
171 self.sprite.changed = True #TODO
172
173
174 def update(self):
175 if self.anmrunner and not self.anmrunner.run_frame():
176 self.anmrunner = None
177
178