comparison pytouhou/game/bullet.py @ 220:0595315d3880

Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 18 Dec 2011 14:14:32 +0100
parents ee0bbde02c48
children 8843e26f80c3
comparison
equal deleted inserted replaced
219:091301805cce 220:0595315d3880
19 from pytouhou.game.sprite import Sprite 19 from pytouhou.game.sprite import Sprite
20 20
21 21
22 class Bullet(object): 22 class Bullet(object):
23 def __init__(self, pos, bullet_type, sprite_idx_offset, 23 def __init__(self, pos, bullet_type, sprite_idx_offset,
24 angle, speed, attributes, flags, player, game, player_bullet=False): 24 angle, speed, attributes, flags, player, game,
25 player_bullet=False, damage=0, hitbox=None):
25 self._game = game 26 self._game = game
26 self._sprite = None 27 self._sprite = None
27 self._anmrunner = None 28 self._anmrunner = None
28 self._removed = False 29 self._removed = False
29 self._launched = False 30 self._launched = False
30 self._bullet_type = bullet_type 31 self._bullet_type = bullet_type
31 32
32 self.hitbox_half_size = bullet_type.hitbox_size / 2. 33 if hitbox:
34 self.hitbox_half_size = (hitbox[0] / 2., hitbox[1] / 2.)
35 else:
36 self.hitbox_half_size = (bullet_type.hitbox_size / 2., bullet_type.hitbox_size / 2.)
33 37
34 self.speed_interpolator = None 38 self.speed_interpolator = None
35 self.frame = 0 39 self.frame = 0
36 self.grazed = False 40 self.grazed = False
37 41
47 self.speed = speed 51 self.speed = speed
48 dx, dy = cos(angle) * speed, sin(angle) * speed 52 dx, dy = cos(angle) * speed, sin(angle) * speed
49 self.delta = dx, dy 53 self.delta = dx, dy
50 54
51 self.player_bullet = player_bullet 55 self.player_bullet = player_bullet
56 self.damage = damage
52 57
53 #TODO 58 #TODO
54 if flags & 14: 59 if flags & 14:
55 if flags & 2: 60 if flags & 2:
56 index = bullet_type.launch_anim2_index 61 index = bullet_type.launch_anim2_index