diff pytouhou/ui/window.pyx @ 463:11708a1d0a1a

Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 11 Sep 2013 00:36:52 +0200
parents ec327e58b477
children 36bc577b2392
line wrap: on
line diff
--- a/pytouhou/ui/window.pyx
+++ b/pytouhou/ui/window.pyx
@@ -74,6 +74,18 @@ cdef class Clock:
 
 
 
+cdef class Runner:
+    cdef void start(self) except *:
+        pass
+
+    cdef void finish(self) except *:
+        pass
+
+    cdef bint update(self) except *:
+        return False
+
+
+
 cdef class Window:
     def __init__(self, tuple size=None, bint double_buffer=True, long fps_limit=-1,
                  bint fixed_pipeline=False, bint sound=True):
@@ -115,7 +127,7 @@ cdef class Window:
         self.win.set_window_size(width, height)
 
 
-    cpdef set_runner(self, runner=None):
+    cpdef set_runner(self, Runner runner=None):
         self.runner = runner
         if runner is not None:
             runner.start()
@@ -138,5 +150,5 @@ cdef class Window:
         return running
 
 
-    cpdef double get_fps(self):
+    cdef double get_fps(self) nogil:
         return self.clock.get_fps()