Mercurial > touhou
diff pytouhou/game/enemy.pyx @ 486:2f53be1b2f60
Merge netplay branch.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 27 Sep 2013 19:01:47 +0200 |
parents | pytouhou/game/enemy.py@1de67f332f00 pytouhou/game/enemy.py@06f0eeb519bb |
children | 887de1309491 |
line wrap: on
line diff
--- a/pytouhou/game/enemy.pyx +++ b/pytouhou/game/enemy.pyx @@ -213,7 +213,7 @@ cdef class Enemy(Element): cpdef Player select_player(self, list players=None): if players is None: players = self._game.players - return players[0] #TODO + return min(players, key=self.select_player_key) cpdef double get_player_angle(self, tuple pos=None, Player player=None): @@ -540,3 +540,6 @@ cdef class Enemy(Element): self.frame += 1 + + def select_player_key(self, p): + return ((p.x - self.x) ** 2 + (p.y - self.y) ** 2, p.state.character)