comparison pytouhou/game/enemy.py @ 354:89ee09453906

Fix callbacks
author Thibaut Girka <thib@sitedethib.com>
date Sat, 07 Jul 2012 23:06:15 +0200
parents b3049fb5c448
children 26f78fc7acea
comparison
equal deleted inserted replaced
353:451bee1d2cec 354:89ee09453906
361 361
362 362
363 def handle_callbacks(self): 363 def handle_callbacks(self):
364 #TODO: implement missing callbacks and clean up! 364 #TODO: implement missing callbacks and clean up!
365 if self.life <= 0 and self.touchable: 365 if self.life <= 0 and self.touchable:
366 self.timeout = -1 #TODO: not really true, the timeout is frozen
367 self.timeout_callback = -1
366 death_flags = self.death_flags & 7 368 death_flags = self.death_flags & 7
367 369
368 self.die_anim() 370 self.die_anim()
369 371
370 #TODO: verify if the score is added with all the different flags. 372 #TODO: verify if the score is added with all the different flags.
410 self.process.switch_to_sub(self.death_callback) 412 self.process.switch_to_sub(self.death_callback)
411 self.death_callback = -1 413 self.death_callback = -1
412 elif self.life <= self.low_life_trigger and self.low_life_callback > -1: 414 elif self.life <= self.low_life_trigger and self.low_life_callback > -1:
413 self.process.switch_to_sub(self.low_life_callback) 415 self.process.switch_to_sub(self.low_life_callback)
414 self.low_life_callback = -1 416 self.low_life_callback = -1
417 self.low_life_trigger = -1
418 self.timeout_callback = -1
415 elif self.timeout != -1 and self.frame == self.timeout: 419 elif self.timeout != -1 and self.frame == self.timeout:
416 self.frame = 0 420 self.timeout = -1
421
422 if self.low_life_trigger > 0:
423 self.life = self.low_life_trigger
424 self.low_life_trigger = -1
425
417 if self.timeout_callback > -1: 426 if self.timeout_callback > -1:
418 self.process.switch_to_sub(self.timeout_callback) 427 self.process.switch_to_sub(self.timeout_callback)
419 self.timeout_callback = -1 428 self.timeout_callback = -1
420 elif self.touchable: 429 #TODO: this is only done under certain (unknown) conditions!
421 self.life = 0 430 # but it shouldn't hurt anyway, as the only option left is to crash!
422 elif self.death_callback > -1: 431 elif self.death_callback > -1:
423 self.process.switch_to_sub(self.death_callback) 432 self.process.switch_to_sub(self.death_callback)
433 self.timeout_callback = -1
424 self.death_callback = -1 434 self.death_callback = -1
425 self.timeout = -1 #TODO: check
426 else: 435 else:
427 raise Exception('What the hell, man!') 436 raise Exception('What the hell, man!')
428 437
429 438
430 def update(self): 439 def update(self):