Mercurial > touhou
changeset 93:d167280a82fc
Handle timeout callbacks, and clean up unneeded things
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 04 Sep 2011 17:34:45 +0200 |
parents | 85f3b8ba3f24 |
children | ca571697ec83 |
files | pytouhou/game/enemymanager.py pytouhou/vm/eclrunner.py |
diffstat | 2 files changed, 16 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/game/enemymanager.py +++ b/pytouhou/game/enemymanager.py @@ -271,7 +271,6 @@ class EnemyManager(object): self.anm_wrapper = anm_wrapper self.main = [] self.ecl = ecl - self.objects_by_texture = {} self.enemies = [] self.processes = [] self.bullets = [] @@ -297,7 +296,7 @@ class EnemyManager(object): def update(self, frame): if self.main and self.main[0][0] == frame: for sub, instr_type, args in self.main.pop(0)[1]: - if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy + if instr_type in (0, 2, 4, 6) and not self._game_state.boss: x, y, z, life, unknown1, unknown2, unknown3 = args if instr_type & 4: if x < -990: #102h.exe@0x411820 @@ -350,13 +349,3 @@ class EnemyManager(object): if self._game_state.boss and self._game_state.boss._removed: self._game_state.boss = None - #TODO - self.objects_by_texture = {} - self.get_objects_by_texture(self.objects_by_texture) - for key, (nb_vertices, vertices, uvs, colors) in self.objects_by_texture.items(): - nb_vertices = len(vertices) - vertices = pack('f' * (3 * nb_vertices), *chain(*vertices)) - uvs = pack('f' * (2 * nb_vertices), *chain(*uvs)) - colors = pack('B' * (4 * nb_vertices), *chain(*colors)) - self.objects_by_texture[key] = (nb_vertices, vertices, uvs, colors) -
--- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -46,13 +46,27 @@ class ECLRunner(object): self.stack = [] + def handle_callbacks(self): + #TODO + enm = self._enemy + if enm.timeout and enm.frame == enm.timeout: + enm.frame = 0 + if enm.timeout_callback: + self.frame = 0 + self.sub = enm.timeout_callback + self.instruction_pointer = 0 + else: + pass #TODO + #TODO: other callbacks (low life, etc.) + + def run_iteration(self): # First, if enemy is dead, return if self._enemy._removed: return False # Then, check for callbacks - #TODO + self.handle_callbacks() # Now, process script while True: