comparison pytouhou/game/enemy.py @ 104:6c59d0eeb5fa

Implement ECL instruction 75 in the same exact way as 102h.exe
author Thibaut Girka <thib@sitedethib.com>
date Mon, 05 Sep 2011 17:18:23 +0200
parents 789994275968
children 572740acdb25
comparison
equal deleted inserted replaced
103:789994275968 104:6c59d0eeb5fa
87 87
88 def fire(self): 88 def fire(self):
89 (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, 89 (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots,
90 speed, speed2, launch_angle, angle, flags) = self.bullet_attributes 90 speed, speed2, launch_angle, angle, flags) = self.bullet_attributes
91 91
92 if speed2 < 0.3:
93 speed2 = 0.3
94
92 self.bullet_launch_timer = 0 95 self.bullet_launch_timer = 0
93 96
94 player = self.select_player() 97 player = self.select_player()
95 98
96 if type_ in (67, 69, 71): 99 if type_ in (67, 69, 71):
97 launch_angle += self.get_player_angle(player) 100 launch_angle += self.get_player_angle(player)
98 if type_ in (69, 70, 71): 101 if type_ in (69, 70, 71):
99 angle = 2. * pi / bullets_per_shot 102 angle = 2. * pi / bullets_per_shot
100 if type_ == 71: 103 if type_ == 71:
101 launch_angle += pi / bullets_per_shot 104 launch_angle += pi / bullets_per_shot
102 105 if type_ != 75:
103 launch_angle -= angle * (bullets_per_shot - 1) / 2. 106 launch_angle -= angle * (bullets_per_shot - 1) / 2.
104 107
105 for shot_nb in range(number_of_shots): 108 for shot_nb in range(number_of_shots):
106 shot_speed = speed if shot_nb == 0 else speed + (speed2 - speed) * float(shot_nb) / float(number_of_shots) 109 shot_speed = speed if shot_nb == 0 else speed + (speed2 - speed) * float(shot_nb) / float(number_of_shots)
107 bullet_angle = launch_angle 110 bullet_angle = launch_angle
108 for bullet_nb in range(bullets_per_shot): 111 for bullet_nb in range(bullets_per_shot):
112 if type_ == 75: # 102.h@0x4138cf
113 bullet_angle = self._game_state.prng.rand_double() * (launch_angle - angle) + angle
114 shot_speed = self._game_state.prng.rand_double() * (speed - speed2) + speed2
109 self.bullets.append(Bullet((self.x, self.y), 115 self.bullets.append(Bullet((self.x, self.y),
110 anim, sprite_idx_offset, 116 anim, sprite_idx_offset,
111 bullet_angle, shot_speed, 117 bullet_angle, shot_speed,
112 self.extended_bullet_attributes, 118 self.extended_bullet_attributes,
113 flags, player, self._game_state)) 119 flags, player, self._game_state))