Mercurial > touhou
comparison pytouhou/game/bullet.pyx @ 606:3c2f96f1d715
Fix compilation under Cython 0.22, by making the pyx and the pxd declarations’ except clause similar.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 26 Nov 2014 13:36:38 +0100 |
parents | f1be00de4b3f |
children | a6af3ff86612 |
comparison
equal
deleted
inserted
replaced
605:d6ead6f0ba80 | 606:3c2f96f1d715 |
---|---|
79 self.sprite.angle = angle - pi | 79 self.sprite.angle = angle - pi |
80 else: | 80 else: |
81 self.sprite.angle = angle | 81 self.sprite.angle = angle |
82 | 82 |
83 | 83 |
84 cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height): | 84 cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height) nogil: |
85 tw, th = self.sprite._texcoords[2], self.sprite._texcoords[3] | 85 tw, th = self.sprite._texcoords[2], self.sprite._texcoords[3] |
86 x, y = self.x, self.y | 86 x, y = self.x, self.y |
87 | 87 |
88 max_x = tw / 2 | 88 max_x = tw / 2 |
89 max_y = th / 2 | 89 max_y = th / 2 |
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) |
111 | 111 |
112 | 112 |
113 cdef void launch(self): | 113 cdef void launch(self) except *: |
114 self.state = LAUNCHED | 114 self.state = LAUNCHED |
115 self.frame = 0 | 115 self.frame = 0 |
116 self.set_anim() | 116 self.set_anim() |
117 self.dx, self.dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed | 117 self.dx, self.dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed |
118 | 118 |
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 cdef void collide(self): | 124 cdef void collide(self) except *: |
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 @cython.cdivision(True) | 129 @cython.cdivision(True) |
130 cdef void cancel(self): | 130 cdef void cancel(self) except *: |
131 # Cancel animation | 131 # Cancel animation |
132 bt = self._bullet_type | 132 bt = self._bullet_type |
133 self.sprite = Sprite() | 133 self.sprite = Sprite() |
134 if self.player >= 0: | 134 if self.player >= 0: |
135 self.sprite.angle = self.angle - pi | 135 self.sprite.angle = self.angle - pi |
143 self.dy /= divisor | 143 self.dy /= divisor |
144 | 144 |
145 self.state = CANCELLED | 145 self.state = CANCELLED |
146 | 146 |
147 | 147 |
148 cdef void update(self): | 148 cdef void update(self) except *: |
149 cdef int frame, count, game_width, game_height | 149 cdef int frame, count, game_width, game_height |
150 cdef double length, angle, speed, acceleration, angular_speed | 150 cdef double length, angle, speed, acceleration, angular_speed |
151 | 151 |
152 if self.anmrunner is not None and not self.anmrunner.run_frame(): | 152 if self.anmrunner is not None and not self.anmrunner.run_frame(): |
153 if self.state == LAUNCHING: | 153 if self.state == LAUNCHING: |