changeset 306:52d791bb7c32

Rename a few attributes/methods to make a little more sense.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 19:18:14 +0100
parents 5492472963b0
children 5930b33a0370
files pytouhou/game/game.py pytouhou/game/item.py pytouhou/ui/gamerenderer.pyx pytouhou/vm/eclrunner.py
diffstat 4 files changed, 25 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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):
--- 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
--- 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
--- 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)