comparison pytouhou/vm/eclrunner.py @ 166:dcf32488a2c9

Better enemy death, with animation and (hopefully) correct flags handling.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Oct 2011 13:17:23 -0700
parents c8c60291c56f
children b96d835c0807
comparison
equal deleted inserted replaced
165:c8c60291c56f 166:dcf32488a2c9
116 if enm.boss_callback is not None: #XXX: MSG's job! 116 if enm.boss_callback is not None: #XXX: MSG's job!
117 self.frame = 0 117 self.frame = 0
118 self.sub = enm.boss_callback 118 self.sub = enm.boss_callback
119 self.instruction_pointer = 0 119 self.instruction_pointer = 0
120 enm.boss_callback = None 120 enm.boss_callback = None
121 if enm.life <= 0: 121 if enm.life <= 0 and enm.touchable:
122 death_flags = enm.death_flags & 7 122 death_flags = enm.death_flags & 7
123
124 enm.die_anim()
123 125
124 if death_flags < 4: 126 if death_flags < 4:
125 if enm._bonus_dropped >= 0: 127 if enm._bonus_dropped >= 0:
126 self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped) 128 self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped)
127 elif enm._bonus_dropped == -1: 129 elif enm._bonus_dropped == -1:
128 self._game.drop_bonus(enm.x, enm.y, self._game.prng.rand_uint16() % 2) #TODO: find the formula in the binary. Can be big power sometimes. 130 self._game.drop_bonus(enm.x, enm.y, self._game.prng.rand_uint16() % 2) #TODO: find the formula in the binary. Can be big power sometimes.
129 131
130 if enm.death_callback is not None: 132 if death_flags == 0:
133 enm._removed = True
134 return
135
136 if death_flags == 1:
137 enm.touchable = False
138 elif death_flags == 2:
139 pass # Just that?
140 elif death_flags == 3:
141 enm.damageable = False
142 enm.life = 1
143 enm.death_flags = 0
144 else:
145 pass #TODO: sparks
146
147 if death_flags != 0 and enm.death_callback is not None:
131 self.frame = 0 148 self.frame = 0
132 self.sub = enm.death_callback 149 self.sub = enm.death_callback
133 self.instruction_pointer = 0 150 self.instruction_pointer = 0
134 enm.death_callback = None 151 enm.death_callback = None
135 elif enm.life <= enm.low_life_trigger and enm.low_life_callback is not None: 152 elif enm.life <= enm.low_life_trigger and enm.low_life_callback is not None:
700 717
701 718
702 @instruction(96) 719 @instruction(96)
703 def kill_enemies(self): 720 def kill_enemies(self):
704 for enemy in self._game.enemies: 721 for enemy in self._game.enemies:
705 enemy.killed() 722 if enemy.touchable:
723 enemy.life = 0
706 724
707 725
708 @instruction(97) 726 @instruction(97)
709 def set_anim(self, sprite_index): 727 def set_anim(self, sprite_index):
710 self._enemy.set_anim(sprite_index) 728 self._enemy.set_anim(sprite_index)