# HG changeset patch # User Thibaut Girka # Date 1331662694 -3600 # Node ID 52d791bb7c325f8a1ab2b77adb6fbdedcb2caf87 # Parent 5492472963b0d1013ff8eec525dc4bb6640f60d3 Rename a few attributes/methods to make a little more sense. diff --git a/pytouhou/game/game.py b/pytouhou/game/game.py --- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -70,8 +70,8 @@ class Game(object): ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage) self.ecl_runner = ECLMainRunner(ecl, self) - self.effect_anm_wrapper = resource_loader.get_anm_wrapper(('eff0%d.anm' % stage,)) - self.effect = None + self.spellcard_effect_anm_wrapper = resource_loader.get_anm_wrapper(('eff0%d.anm' % stage,)) + self.spellcard_effect = None # See 102h.exe@0x413220 if you think you're brave enough. self.deaths_count = self.prng.rand_uint16() % 3 @@ -102,13 +102,14 @@ class Game(object): self.difficulty = self.difficulty_max - def enable_effect(self): - self.effect = Effect((-32., -16.), 0, self.effect_anm_wrapper) #TODO: find why this offset is necessary. - self.effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate! + def enable_spellcard_effect(self): + self.spellcard_effect = Effect((-32., -16.), 0, + self.spellcard_effect_anm_wrapper) #TODO: find why this offset is necessary. + self.spellcard_effect.sprite.allow_dest_offset = True #TODO: should be the role of anm’s 25th instruction. Investigate! - def disable_effect(self): - self.effect = None + def disable_spellcard_effect(self): + self.spellcard_effect = None def drop_bonus(self, x, y, _type, end_pos=None): @@ -178,7 +179,7 @@ class Game(object): # We have to mimic this functionnality to be replay-compatible with the official game. # Pri 6 is background - self.update_effect() #TODO: Pri unknown + self.update_background() #TODO: Pri unknown if self.msg_runner: self.update_msg(keystate) # Pri ? keystate &= ~3 # Remove the ability to attack (keystates 1 and 2). @@ -196,11 +197,12 @@ class Game(object): self.frame += 1 - def update_effect(self): + def update_background(self): if self.time_stop: return None - if self.effect is not None: - self.effect.update() + if self.spellcard_effect is not None: + self.spellcard_effect.update() + #TODO: update the actual background here? def update_enemies(self): diff --git a/pytouhou/game/item.py b/pytouhou/game/item.py --- a/pytouhou/game/item.py +++ b/pytouhou/game/item.py @@ -21,10 +21,10 @@ from pytouhou.utils.interpolator import class Item(object): def __init__(self, start_pos, _type, item_type, game, angle=pi/2, player=None, end_pos=None): self._game = game + self._item_type = item_type self.sprite = item_type.sprite self.removed = False self._type = _type - self._item_type = item_type self.frame = 0 self.x, self.y = start_pos diff --git a/pytouhou/ui/gamerenderer.pyx b/pytouhou/ui/gamerenderer.pyx --- a/pytouhou/ui/gamerenderer.pyx +++ b/pytouhou/ui/gamerenderer.pyx @@ -45,11 +45,11 @@ cdef class GameRenderer(Renderer): game = self.game texture_manager = self.texture_manager - if game is not None and game.effect is not None: + if game is not None and game.spellcard_effect is not None: self.setup_camera(0, 0, 1) glDisable(GL_FOG) - self.render_elements([game.effect]) + self.render_elements([game.spellcard_effect]) glEnable(GL_FOG) elif back is not None: fog_b, fog_g, fog_r, fog_start, fog_end = back.fog_interpolator.values diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -27,13 +27,13 @@ class ECLMainRunner(object): __metaclass__ = MetaRegistry __slots__ = ('_ecl', '_game', 'processes', 'frame', 'instruction_pointer', - 'time_stopped') + 'boss_wait') def __init__(self, ecl, game): self._ecl = ecl self._game = game self.frame = 0 - self.time_stopped = False + self.boss_wait = False self.processes = [] @@ -42,7 +42,7 @@ class ECLMainRunner(object): def run_iter(self): if not self._game.boss: - self.time_stopped = False + self.boss_wait = False while True: try: @@ -51,7 +51,7 @@ class ECLMainRunner(object): break # The msg_wait instruction stops the reading of the ECL, not just the frame incrementation. - if frame > self.frame or self._game.msg_wait or self.time_stopped: + if frame > self.frame or self._game.msg_wait or self.boss_wait: break else: self.instruction_pointer += 1 @@ -67,7 +67,7 @@ class ECLMainRunner(object): self.processes[:] = (process for process in self.processes if process.run_iteration()) - if not (self._game.msg_wait or self.time_stopped): + if not (self._game.msg_wait or self.boss_wait): self.frame += 1 @@ -120,8 +120,8 @@ class ECLMainRunner(object): @instruction(12) - def stop_time(self, sub, instr_type): - self.time_stopped = True + def wait_for_boss_death(self, sub, instr_type): + self.boss_wait = True @@ -808,7 +808,7 @@ class ECLRunner(object): #TODO: make the enemies more resistants (and find how). self._game.change_bullets_into_star_items() self._game.spellcard = (number, name) - self._game.enable_effect() + self._game.enable_spellcard_effect() @instruction(94) @@ -818,7 +818,7 @@ class ECLRunner(object): if self._game.spellcard: self._game.change_bullets_into_star_items() self._game.spellcard = None - self._game.disable_effect() + self._game.disable_spellcard_effect() @instruction(95)