Mercurial > touhou
comparison pytouhou/game/enemy.py @ 335:2350147cf043
Fix bullet cancellation and removal
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 01 Jul 2012 11:43:38 +0200 |
parents | 1bb78c469f64 |
children | 94fdb6c782c1 |
comparison
equal
deleted
inserted
replaced
334:4eca6130f118 | 335:2350147cf043 |
---|---|
18 from pytouhou.game.sprite import Sprite | 18 from pytouhou.game.sprite import Sprite |
19 from pytouhou.game.bullet import Bullet | 19 from pytouhou.game.bullet import Bullet |
20 from pytouhou.game.laser import Laser | 20 from pytouhou.game.laser import Laser |
21 from pytouhou.game.effect import Effect | 21 from pytouhou.game.effect import Effect |
22 from math import cos, sin, atan2, pi | 22 from math import cos, sin, atan2, pi |
23 from pytouhou.game.bullet import LAUNCHED | |
23 | 24 |
24 | 25 |
25 class Enemy(object): | 26 class Enemy(object): |
26 def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game): | 27 def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game): |
27 self._game = game | 28 self._game = game |
278 | 279 |
279 damages = 0 | 280 damages = 0 |
280 | 281 |
281 # Check for enemy-bullet collisions | 282 # Check for enemy-bullet collisions |
282 for bullet in self._game.players_bullets: | 283 for bullet in self._game.players_bullets: |
284 if bullet.state != LAUNCHED: | |
285 continue | |
283 half_size = bullet.hitbox_half_size | 286 half_size = bullet.hitbox_half_size |
284 bx, by = bullet.x, bullet.y | 287 bx, by = bullet.x, bullet.y |
285 bx1, bx2 = bx - half_size[0], bx + half_size[0] | 288 bx1, bx2 = bx - half_size[0], bx + half_size[0] |
286 by1, by2 = by - half_size[1], by + half_size[1] | 289 by1, by2 = by - half_size[1], by + half_size[1] |
287 | 290 |