diff pytouhou/ui/window.pyx @ 594:12756994a92c

Make frameskip actually skip the rendering part, not just the buffer swap.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 18 Oct 2014 18:04:43 +0200
parents 0768122da817
children ab131d04987d
line wrap: on
line diff
--- a/pytouhou/ui/window.pyx
+++ b/pytouhou/ui/window.pyx
@@ -71,7 +71,7 @@ cdef class Runner:
     cdef void finish(self) except *:
         pass
 
-    cpdef bint update(self) except? False:
+    cpdef bint update(self, bint render) except? False:
         return False
 
 
@@ -109,14 +109,20 @@ cdef class Window:
                 self.runner.finish()
 
 
+    @cython.cdivision(True)
     cdef bint run_frame(self) except? False:
-        cdef bint running = False
+        cdef bint render = (self.win is not None and
+                            (self.frameskip <= 1 or not self.frame % self.frameskip))
+
+        running = False
         if self.runner is not None:
-            running = self.runner.update()
-        if self.win is not None and (self.frameskip <= 1 or not self.frame % self.frameskip):
+            running = self.runner.update(render)
+        if render:
             self.win.present()
+
         self.clock.tick()
         self.frame += 1
+
         return running