comparison pytouhou/game/enemy.pyx @ 617:a6af3ff86612

Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 Mar 2015 00:08:20 +0100
parents 3c2f96f1d715
children
comparison
equal deleted inserted replaced
616:4ce3ef053a25 617:a6af3ff86612
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) except *: 264 cdef bint die_anim(self) except True:
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) except *: 270 cdef bint drop_particles(self, long number, long color) except True:
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):
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) except *: 341 cdef bint check_collisions(self) except True:
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) except *: 429 cdef bint handle_callbacks(self) except True:
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
457 else: 457 else:
458 self.drop_particles(4, 0) 458 self.drop_particles(4, 0)
459 459
460 if death_flags == 0: 460 if death_flags == 0:
461 self.removed = True 461 self.removed = True
462 return 462 return False
463 463
464 if death_flags == 1: 464 if death_flags == 1:
465 if self.boss: 465 if self.boss:
466 self.boss = False #TODO: really? 466 self.boss = False #TODO: really?
467 self._game.boss = None 467 self._game.boss = None
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) except *: 505 cdef bint update(self) except True:
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