diff pytouhou/game/eclrunner.py @ 30:e3ba2fa966f6

Various optimizations
author Thibaut Girka <thib@sitedethib.com>
date Fri, 12 Aug 2011 23:47:34 +0200
parents 93aa1b55d97c
children 1b0ca2fb89f9
line wrap: on
line diff
--- a/pytouhou/game/eclrunner.py
+++ b/pytouhou/game/eclrunner.py
@@ -38,21 +38,21 @@ class ECLRunner(object):
 
     def update(self):
         frame = self.frame
-        while frame <= self.frame:
-            try:
+        try:
+            while frame <= self.frame:
                 frame, instr_type, rank_mask, param_mask, args = self.ecl.subs[self.sub][self.instruction_pointer]
-            except IndexError:
-                break #TODO: script ended, destroy enemy
 
-            if frame == self.frame:
-                try:
-                    format, callback = self.implementation[instr_type]
-                except KeyError:
-                    print('Warning: unhandled opcode %d!' % instr_type) #TODO
-                else:
-                    callback(*unpack('<' + format, args))
-            if frame <= self.frame:
-                self.instruction_pointer += 1
+                if frame == self.frame:
+                    try:
+                        format, callback = self.implementation[instr_type]
+                    except KeyError:
+                        print('Warning: unhandled opcode %d!' % instr_type) #TODO
+                    else:
+                        callback(*unpack('<' + format, args))
+                if frame <= self.frame:
+                    self.instruction_pointer += 1
+        except IndexError:
+            pass #TODO: script ended, destroy enemy
 
         self.frame += 1