comparison pytouhou/game/bullet.pyx @ 468:feecdb4a8928

Add “except *” to cdef void functions, and type some more.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 12 Sep 2013 15:47:08 +0200
parents 3bc37791f0a2
children 8038f1957b71
comparison
equal deleted inserted replaced
467:5bb7d2c0ff46 468:feecdb4a8928
19 19
20 20
21 cdef class Bullet(Element): 21 cdef class Bullet(Element):
22 def __init__(self, pos, bullet_type, unsigned long sprite_idx_offset, 22 def __init__(self, pos, 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, hitbox=None): 24 bint player_bullet=False, 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
30 self._bullet_type = bullet_type 30 self._bullet_type = bullet_type
31 self.state = LAUNCHING 31 self.state = LAUNCHING
32 self.was_visible = True 32 self.was_visible = True
33 33
34 if hitbox is not None: 34 if hitbox is not None:
35 self.hitbox = hitbox 35 self.hitbox[:] = [hitbox[0], hitbox[1]]
36 else: 36 else:
37 self.hitbox = (bullet_type.hitbox_size, bullet_type.hitbox_size) 37 self.hitbox[:] = [bullet_type.hitbox_size, bullet_type.hitbox_size]
38 38
39 self.speed_interpolator = None 39 self.speed_interpolator = None
40 self.frame = 0 40 self.frame = 0
41 self.grazed = False 41 self.grazed = False
42 42
119 if self.flags & 1: 119 if self.flags & 1:
120 self.speed_interpolator = Interpolator((self.speed + 5.,), 0, 120 self.speed_interpolator = Interpolator((self.speed + 5.,), 0,
121 (self.speed,), 16) 121 (self.speed,), 16)
122 122
123 123
124 cpdef collide(self): 124 cdef void collide(self):
125 self.cancel() 125 self.cancel()
126 self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size. 126 self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size.
127 127
128 128
129 cpdef 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_bullet:
134 self.sprite.angle = self.angle - pi 134 self.sprite.angle = self.angle - pi
139 self.dx, self.dy = self.dx / 2., self.dy / 2. 139 self.dx, self.dy = self.dx / 2., self.dy / 2.
140 140
141 self.state = CANCELLED 141 self.state = CANCELLED
142 142
143 143
144 cpdef update(self): 144 cdef void update(self):
145 cdef int frame, count, game_width, game_height 145 cdef int frame, count, game_width, game_height
146 cdef double length, angle, speed, acceleration, angular_speed 146 cdef double length, angle, speed, acceleration, angular_speed
147 147
148 if self.anmrunner is not None and not self.anmrunner.run_frame(): 148 if self.anmrunner is not None and not self.anmrunner.run_frame():
149 if self.state == LAUNCHING: 149 if self.state == LAUNCHING: