Mercurial > touhou
comparison pytouhou/vm/eclrunner.py @ 103:789994275968
Fix boss callback, handle a few more callbacks
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 05 Sep 2011 01:07:43 +0200 |
parents | ad9297e0fbf2 |
children | 572740acdb25 |
comparison
equal
deleted
inserted
replaced
102:ad9297e0fbf2 | 103:789994275968 |
---|---|
104 | 104 |
105 self.stack = [] | 105 self.stack = [] |
106 | 106 |
107 | 107 |
108 def handle_callbacks(self): | 108 def handle_callbacks(self): |
109 #TODO | 109 #TODO: implement missing callbacks and clean up! |
110 enm = self._enemy | 110 enm = self._enemy |
111 if enm.timeout and enm.frame == enm.timeout: | 111 if enm.boss_callback is not None: #XXX: MSG's job! |
112 self.frame = 0 | |
113 self.sub = enm.boss_callback | |
114 self.instruction_pointer = 0 | |
115 enm.boss_callback = None | |
116 if enm.life == 0 and enm.death_callback is not None: | |
117 self.frame = 0 | |
118 self.sub = enm.death_callback | |
119 self.instruction_pointer = 0 | |
120 #TODO: various things, like deleting the character | |
121 enm.death_callback = None #XXX | |
122 elif enm.timeout and enm.frame == enm.timeout: | |
112 enm.frame = 0 | 123 enm.frame = 0 |
113 if enm.timeout_callback: | 124 if enm.timeout_callback is not None: |
114 self.frame = 0 | 125 self.frame = 0 |
115 self.sub = enm.timeout_callback | 126 self.sub = enm.timeout_callback |
116 self.instruction_pointer = 0 | 127 self.instruction_pointer = 0 |
128 enm.timeout_callback = None | |
117 else: | 129 else: |
118 pass #TODO | 130 enm.life = 0 |
119 #TODO: other callbacks (low life, etc.) | 131 #TODO: other callbacks (low life, etc.) |
120 | 132 |
121 | 133 |
122 def run_iteration(self): | 134 def run_iteration(self): |
123 # First, if enemy is dead, return | 135 # First, if enemy is dead, return |
693 @instruction(109) | 705 @instruction(109) |
694 def memory_write(self, value, index): | 706 def memory_write(self, value, index): |
695 #TODO | 707 #TODO |
696 #XXX: this is a hack to display bosses although we don't handle MSG :) | 708 #XXX: this is a hack to display bosses although we don't handle MSG :) |
697 if index == 0: | 709 if index == 0: |
698 self.sub = value | 710 self._enemy.boss_callback = value |
699 self.frame = 0 | 711 else: |
700 self.instruction_pointer = 0 | 712 raise Exception #TODO |
701 | 713 |
702 | 714 |
703 @instruction(111) | 715 @instruction(111) |
704 def set_life(self, value): | 716 def set_life(self, value): |
705 self._enemy.life = value | 717 self._enemy.life = value |