Mercurial > touhou
comparison pytouhou/game/enemy.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 | e15672733c93 |
children | a6af3ff86612 |
comparison
equal
deleted
inserted
replaced
605:d6ead6f0ba80 | 606:3c2f96f1d715 |
---|---|
247 if players is None: | 247 if players is None: |
248 players = self._game.players | 248 players = self._game.players |
249 return min(players, key=self.select_player_key) | 249 return min(players, key=self.select_player_key) |
250 | 250 |
251 | 251 |
252 cpdef double get_angle(self, Element target, tuple pos=None): | 252 cpdef double get_angle(self, Element target, tuple pos=None) except 42: |
253 cdef double x, y | 253 cdef double x, y |
254 x, y = pos or (self.x, self.y) | 254 x, y = pos or (self.x, self.y) |
255 return atan2(target.y - y, target.x - x) | 255 return atan2(target.y - y, target.x - x) |
256 | 256 |
257 | 257 |
259 entry = 0 if index in self._anms[0].scripts else 1 | 259 entry = 0 if index in self._anms[0].scripts else 1 |
260 self.sprite = Sprite() | 260 self.sprite = Sprite() |
261 self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite) | 261 self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite) |
262 | 262 |
263 | 263 |
264 cdef void die_anim(self): | 264 cdef void die_anim(self) except *: |
265 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs. | 265 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs. |
266 self._game.new_effect((self.x, self.y), anim) | 266 self._game.new_effect((self.x, self.y), anim) |
267 self._game.sfx_player.play('enep00.wav') | 267 self._game.sfx_player.play('enep00.wav') |
268 | 268 |
269 | 269 |
270 cdef void drop_particles(self, long number, long color): | 270 cdef void drop_particles(self, long number, long color) except *: |
271 if color == 0: | 271 if color == 0: |
272 if self._game.stage in [1, 2, 7]: | 272 if self._game.stage in [1, 2, 7]: |
273 color = 3 | 273 color = 3 |
274 color += 9 | 274 color += 9 |
275 for i in range(number): | 275 for i in range(number): |
316 else: | 316 else: |
317 self.boss = False | 317 self.boss = False |
318 self._game.boss = None | 318 self._game.boss = None |
319 | 319 |
320 | 320 |
321 cdef bint is_visible(self, long screen_width, long screen_height): | 321 cdef bint is_visible(self, long screen_width, long screen_height) except -1: |
322 if self.sprite is not None: | 322 if self.sprite is not None: |
323 if self.sprite.corner_relative_placement: | 323 if self.sprite.corner_relative_placement: |
324 raise Exception #TODO | 324 raise Exception #TODO |
325 tw, th = self.sprite._texcoords[2], self.sprite._texcoords[3] | 325 tw, th = self.sprite._texcoords[2], self.sprite._texcoords[3] |
326 else: | 326 else: |
336 or max_y < -y): | 336 or max_y < -y): |
337 return False | 337 return False |
338 return True | 338 return True |
339 | 339 |
340 | 340 |
341 cdef void check_collisions(self): | 341 cdef void check_collisions(self) except *: |
342 cdef Bullet bullet | 342 cdef Bullet bullet |
343 cdef Player player | 343 cdef Player player |
344 cdef PlayerLaser laser | 344 cdef PlayerLaser laser |
345 cdef long damages | 345 cdef long damages |
346 cdef double half_size[2] | 346 cdef double half_size[2] |
424 | 424 |
425 # Apply damages | 425 # Apply damages |
426 self.life -= damages | 426 self.life -= damages |
427 | 427 |
428 | 428 |
429 cdef void handle_callbacks(self): | 429 cdef void handle_callbacks(self) except *: |
430 #TODO: implement missing callbacks and clean up! | 430 #TODO: implement missing callbacks and clean up! |
431 if self.life <= 0 and self.touchable: | 431 if self.life <= 0 and self.touchable: |
432 self.timeout = -1 #TODO: not really true, the timeout is frozen | 432 self.timeout = -1 #TODO: not really true, the timeout is frozen |
433 self.timeout_callback.disable() | 433 self.timeout_callback.disable() |
434 death_flags = self.death_flags & 7 | 434 death_flags = self.death_flags & 7 |
500 self.life = 0 #TODO: do this next frame? Bypass self.touchable? | 500 self.life = 0 #TODO: do this next frame? Bypass self.touchable? |
501 else: | 501 else: |
502 raise Exception('What the hell, man!') | 502 raise Exception('What the hell, man!') |
503 | 503 |
504 | 504 |
505 cdef void update(self): | 505 cdef void update(self) except *: |
506 cdef double x, y, speed | 506 cdef double x, y, speed |
507 | 507 |
508 if self.process is not None: | 508 if self.process is not None: |
509 self.process.run_iteration() | 509 self.process.run_iteration() |
510 | 510 |