comparison pytouhou/vm/eclrunner.py @ 154:364935f6e313

Implement enemy killing.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 09 Oct 2011 16:55:18 -0700
parents 86807b8a63bd
children ed86bec43b93
comparison
equal deleted inserted replaced
153:37df8c618c2e 154:364935f6e313
68 x = self._game.prng.rand_double() * 368 68 x = self._game.prng.rand_double() * 368
69 if y < -990: #102h.exe@0x41184b 69 if y < -990: #102h.exe@0x41184b
70 y = self._game.prng.rand_double() * 416 70 y = self._game.prng.rand_double() * 416
71 if z < -990: #102h.exe@0x411881 71 if z < -990: #102h.exe@0x411881
72 y = self._game.prng.rand_double() * 800 72 y = self._game.prng.rand_double() * 800
73 enemy = self._new_enemy_func((x, y), life, instr_type, self._pop_enemy) 73 enemy = self._new_enemy_func((x, y), life, instr_type, bonus_dropped, self._pop_enemy)
74 process = ECLRunner(self._ecl, sub, enemy, self._game) 74 process = ECLRunner(self._ecl, sub, enemy, self._game)
75 self.processes.append(process) 75 self.processes.append(process)
76 process.run_iteration() 76 process.run_iteration()
77 77
78 78
672 @instruction(95) 672 @instruction(95)
673 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, unknown2): 673 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, unknown2):
674 self._enemy.pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, unknown2, 0) # TODO: check about unknown values 674 self._enemy.pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, unknown2, 0) # TODO: check about unknown values
675 675
676 676
677 @instruction(96)
678 def kill_enemies(self):
679 for enemy in self._game.enemies:
680 enemy.killed()
681
682
677 @instruction(97) 683 @instruction(97)
678 def set_anim(self, sprite_index): 684 def set_anim(self, sprite_index):
679 self._enemy.set_anim(sprite_index) 685 self._enemy.set_anim(sprite_index)
680 686
681 687
774 """Defines whether the enemy is “touchable”. 780 """Defines whether the enemy is “touchable”.
775 Bullets only collide with an enemy if it is “touchable”. 781 Bullets only collide with an enemy if it is “touchable”.
776 Likewise, ReimuA's homing attacks only target “touchable” enemies. 782 Likewise, ReimuA's homing attacks only target “touchable” enemies.
777 """ 783 """
778 self._enemy.touchable = bool(value) 784 self._enemy.touchable = bool(value)
785
786
787 @instruction(119)
788 def drop_some_bonus(self, number):
789 for i in range(number):
790 #TODO: find the formula in the binary.
791 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128,
792 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128, 0)
779 793
780 794
781 @instruction(120) 795 @instruction(120)
782 def set_automatic_orientation(self, flags): 796 def set_automatic_orientation(self, flags):
783 #TODO: does it change anything else than the sprite's rotation? 797 #TODO: does it change anything else than the sprite's rotation?
805 def skip_frames(self, frames): 819 def skip_frames(self, frames):
806 #TODO: is that all? 820 #TODO: is that all?
807 self.frame += self._getval(frames) 821 self.frame += self._getval(frames)
808 822
809 823
824 @instruction(124)
825 def drop_specific_bonus(self, _type):
826 self._game.drop_bonus(self._enemy.x, self._enemy.y, _type)
827
828
810 @instruction(126) 829 @instruction(126)
811 def set_remaining_lives(self, lives): 830 def set_remaining_lives(self, lives):
812 self._enemy.remaining_lives = lives 831 self._enemy.remaining_lives = lives
813 832