diff pytouhou/vm/eclrunner.py @ 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 f7525fa66bb0
children e2d8f2a56ea4
line wrap: on
line diff
--- 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: