changeset 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 fab7ad2f0d8b
children 2cad2e84a49e
files pytouhou/game/enemy.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -97,7 +97,7 @@ class Enemy(object):
         player = self.select_player()
 
         if type_ in (67, 69, 71):
-            launch_angle += self.get_player_angle(player)
+            launch_angle += self.get_player_angle(player, launch_pos)
         if type_ in (69, 70, 71):
             angle = 2. * pi / bullets_per_shot
         if type_ == 71:
@@ -125,9 +125,10 @@ class Enemy(object):
         return (players or self._game_state.players)[0] #TODO
 
 
-    def get_player_angle(self, player=None):
+    def get_player_angle(self, player=None, pos=None):
         player = player or self.select_player()
-        return atan2(player.y - self.y, player.x - self.x)
+        x, y = pos or (self.x, self.y)
+        return atan2(player.y - y, player.x - x)
 
 
     def set_anim(self, index):