comparison pytouhou/game/bullet.pyx @ 492:887de1309491

Add friendly fire in netplay.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 21 Sep 2013 20:26:39 +0200
parents 8038f1957b71
children db28538cd399
comparison
equal deleted inserted replaced
491:2276229282fd 492:887de1309491
19 19
20 20
21 cdef class Bullet(Element): 21 cdef class Bullet(Element):
22 def __init__(self, pos, BulletType bullet_type, unsigned long sprite_idx_offset, 22 def __init__(self, pos, BulletType bullet_type, unsigned long sprite_idx_offset,
23 double angle, double speed, attributes, unsigned long flags, target, Game game, 23 double angle, double speed, attributes, unsigned long flags, target, Game game,
24 bint player_bullet=False, unsigned long damage=0, tuple hitbox=None): 24 long player=-1, unsigned long damage=0, tuple hitbox=None):
25 cdef double launch_mult 25 cdef double launch_mult
26 26
27 Element.__init__(self, pos) 27 Element.__init__(self, pos)
28 28
29 self._game = game 29 self._game = game
49 49
50 self.angle = angle 50 self.angle = angle
51 self.speed = speed 51 self.speed = speed
52 self.dx, self.dy = cos(angle) * speed, sin(angle) * speed 52 self.dx, self.dy = cos(angle) * speed, sin(angle) * speed
53 53
54 self.player_bullet = player_bullet 54 self.player = player
55 self.damage = damage 55 self.damage = damage
56 56
57 #TODO 57 #TODO
58 if flags & 14: 58 if flags & 14:
59 if flags & 2: 59 if flags & 2:
71 index, self.sprite, 71 index, self.sprite,
72 bullet_type.launch_anim_offsets[sprite_idx_offset]) 72 bullet_type.launch_anim_offsets[sprite_idx_offset])
73 else: 73 else:
74 self.launch() 74 self.launch()
75 75
76 if self.player_bullet: 76 if self.player >= 0:
77 self.sprite.angle = angle - pi 77 self.sprite.angle = angle - pi
78 else: 78 else:
79 self.sprite.angle = angle 79 self.sprite.angle = angle
80 80
81 81
100 if sprite_idx_offset is not None: 100 if sprite_idx_offset is not None:
101 self.sprite_idx_offset = sprite_idx_offset 101 self.sprite_idx_offset = sprite_idx_offset
102 102
103 bt = self._bullet_type 103 bt = self._bullet_type
104 self.sprite = Sprite() 104 self.sprite = Sprite()
105 if self.player_bullet: 105 if self.player >= 0:
106 self.sprite.angle = self.angle - pi 106 self.sprite.angle = self.angle - pi
107 else: 107 else:
108 self.sprite.angle = self.angle 108 self.sprite.angle = self.angle
109 self.anmrunner = ANMRunner(bt.anm, bt.anim_index, 109 self.anmrunner = ANMRunner(bt.anm, bt.anim_index,
110 self.sprite, self.sprite_idx_offset) 110 self.sprite, self.sprite_idx_offset)
128 128
129 cdef void cancel(self): 129 cdef void cancel(self):
130 # Cancel animation 130 # Cancel animation
131 bt = self._bullet_type 131 bt = self._bullet_type
132 self.sprite = Sprite() 132 self.sprite = Sprite()
133 if self.player_bullet: 133 if self.player >= 0:
134 self.sprite.angle = self.angle - pi 134 self.sprite.angle = self.angle - pi
135 else: 135 else:
136 self.sprite.angle = self.angle 136 self.sprite.angle = self.angle
137 self.anmrunner = ANMRunner(bt.anm, bt.cancel_anim_index, 137 self.anmrunner = ANMRunner(bt.anm, bt.cancel_anim_index,
138 self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset]) 138 self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset])