Mercurial > touhou
comparison pytouhou/game/enemymanager.py @ 33:1f21bcc0845b
Fix scoping issue with _enemy_deleter
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 13 Aug 2011 00:24:55 +0200 |
parents | 47543594ff66 |
children | 4d93d45ecb62 |
comparison
equal
deleted
inserted
replaced
32:47543594ff66 | 33:1f21bcc0845b |
---|---|
173 self.main.append((frame, [(sub, instr_type, args)])) | 173 self.main.append((frame, [(sub, instr_type, args)])) |
174 elif self.main[-1][0] == frame: | 174 elif self.main[-1][0] == frame: |
175 self.main[-1][1].append((sub, instr_type, args)) | 175 self.main[-1][1].append((sub, instr_type, args)) |
176 | 176 |
177 | 177 |
178 def make_enemy_deleter(self, enemy): | |
179 def _enemy_deleter(unknown): #TODO: unknown | |
180 self.enemies.remove(enemy) | |
181 return _enemy_deleter | |
182 | |
183 | |
178 def update(self, frame): | 184 def update(self, frame): |
179 if self.main and self.main[0][0] == frame: | 185 if self.main and self.main[0][0] == frame: |
180 for sub, instr_type, args in self.main.pop(0)[1]: | 186 for sub, instr_type, args in self.main.pop(0)[1]: |
181 if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy | 187 if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy |
182 x, y, z, life, unknown1, unknown2, unknown3 = args | 188 x, y, z, life, unknown1, unknown2, unknown3 = args |
183 ecl_runner = ECLRunner(self.ecl, sub) | 189 ecl_runner = ECLRunner(self.ecl, sub) |
184 enemy = Enemy((x, y), life, instr_type, ecl_runner, self.anm_wrapper) | 190 enemy = Enemy((x, y), life, instr_type, ecl_runner, self.anm_wrapper) |
185 | 191 |
186 def _enemy_deleter(unknown): #TOOD: unknown | 192 ecl_runner.implementation[1] = ('I', self.make_enemy_deleter(enemy)) |
187 self.enemies.remove(enemy) | |
188 | |
189 ecl_runner.implementation[1] = ('I', _enemy_deleter) | |
190 | 193 |
191 self.enemies.append(enemy) | 194 self.enemies.append(enemy) |
192 | 195 |
193 # Update enemies | 196 # Update enemies |
194 visible_enemies = [enemy for enemy in self.enemies if enemy.update(frame)] | 197 visible_enemies = [enemy for enemy in self.enemies if enemy.update(frame)] |