Mercurial > touhou
comparison pytouhou/games/eosd.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 |
---|---|
19 from pytouhou.game.lasertype import LaserType | 19 from pytouhou.game.lasertype import LaserType |
20 from pytouhou.game.itemtype import ItemType | 20 from pytouhou.game.itemtype import ItemType |
21 from pytouhou.game.player import Player | 21 from pytouhou.game.player import Player |
22 from pytouhou.game.orb import Orb | 22 from pytouhou.game.orb import Orb |
23 from pytouhou.game.effect import Effect | 23 from pytouhou.game.effect import Effect |
24 from pytouhou.game.text import Text, Counter | 24 from pytouhou.game.text import Text, Counter, Gauge |
25 | 25 |
26 | 26 |
27 SQ2 = 2. ** 0.5 / 2. | 27 SQ2 = 2. ** 0.5 / 2. |
28 | 28 |
29 | 29 |
136 } | 136 } |
137 self.labels['boss_lives'].set_color('yellow') | 137 self.labels['boss_lives'].set_color('yellow') |
138 | 138 |
139 self.boss_items = [ | 139 self.boss_items = [ |
140 Effect((0, 0), 19, front), # Enemy | 140 Effect((0, 0), 19, front), # Enemy |
141 # Gauge | 141 Gauge((100, 24), front), # Gauge |
142 ] | 142 ] |
143 for item in self.boss_items: | 143 for item in self.boss_items: |
144 item.sprite.allow_dest_offset = True #XXX | 144 item.sprite.allow_dest_offset = True #XXX |
145 | 145 |
146 self.front = front #XXX | 146 |
147 def set_boss_life(self): | |
148 self.boss_items[1].maximum = self.game.boss._enemy.life | |
147 | 149 |
148 | 150 |
149 def update(self): | 151 def update(self): |
150 for elem in self.items: | 152 for elem in self.items: |
151 elem.update() | 153 elem.update() |
161 self.labels['player'].set_value(player_state.lives) | 163 self.labels['player'].set_value(player_state.lives) |
162 self.labels['bombs'].set_value(player_state.bombs) | 164 self.labels['bombs'].set_value(player_state.bombs) |
163 | 165 |
164 if self.game.boss: | 166 if self.game.boss: |
165 boss = self.game.boss._enemy | 167 boss = self.game.boss._enemy |
168 | |
169 life_gauge = self.boss_items[1] | |
170 life_gauge.set_value(boss.life) | |
171 | |
166 for item in self.boss_items: | 172 for item in self.boss_items: |
167 item.update() | 173 item.update() |
168 | 174 |
169 self.labels['boss_lives'].set_text('%d' % boss.remaining_lives) | 175 self.labels['boss_lives'].set_text('%d' % boss.remaining_lives) |
170 self.labels['boss_lives'].changed = True | 176 self.labels['boss_lives'].changed = True |