comparison pytouhou/game/enemy.py @ 132:fba45c37ec99

Fix initial angle of bullets with bullet_launch_offset enabled.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 11 Sep 2011 05:13:43 -0700
parents 11ab06f4c4c6
children e9ac3640280b
comparison
equal deleted inserted replaced
131:fab7ad2f0d8b 132:fba45c37ec99
95 self.bullet_launch_timer = 0 95 self.bullet_launch_timer = 0
96 96
97 player = self.select_player() 97 player = self.select_player()
98 98
99 if type_ in (67, 69, 71): 99 if type_ in (67, 69, 71):
100 launch_angle += self.get_player_angle(player) 100 launch_angle += self.get_player_angle(player, launch_pos)
101 if type_ in (69, 70, 71): 101 if type_ in (69, 70, 71):
102 angle = 2. * pi / bullets_per_shot 102 angle = 2. * pi / bullets_per_shot
103 if type_ == 71: 103 if type_ == 71:
104 launch_angle += pi / bullets_per_shot 104 launch_angle += pi / bullets_per_shot
105 if type_ != 75: 105 if type_ != 75:
123 123
124 def select_player(self, players=None): 124 def select_player(self, players=None):
125 return (players or self._game_state.players)[0] #TODO 125 return (players or self._game_state.players)[0] #TODO
126 126
127 127
128 def get_player_angle(self, player=None): 128 def get_player_angle(self, player=None, pos=None):
129 player = player or self.select_player() 129 player = player or self.select_player()
130 return atan2(player.y - self.y, player.x - self.x) 130 x, y = pos or (self.x, self.y)
131 return atan2(player.y - y, player.x - x)
131 132
132 133
133 def set_anim(self, index): 134 def set_anim(self, index):
134 self._sprite = Sprite() 135 self._sprite = Sprite()
135 self._anmrunner = ANMRunner(self._anm_wrapper, index, self._sprite) 136 self._anmrunner = ANMRunner(self._anm_wrapper, index, self._sprite)