# HG changeset patch # User Emmanuel Gil Peyrot # Date 1413648283 -7200 # Node ID 12756994a92cfae6a485f12d76ded0610fcd77c0 # Parent 974decb8df4f7984280e4a3c444529f3339f32f4 Make frameskip actually skip the rendering part, not just the buffer swap. diff --git a/pytouhou/ui/gamerunner.pyx b/pytouhou/ui/gamerunner.pyx --- a/pytouhou/ui/gamerunner.pyx +++ b/pytouhou/ui/gamerunner.pyx @@ -114,7 +114,7 @@ cdef class GameRunner(Runner): self.renderer.capture(filename, self.width, self.height) - cpdef bint update(self) except? False: + cpdef bint update(self, bint render) except? False: cdef long keystate capture = False @@ -178,7 +178,7 @@ cdef class GameRunner(Runner): if self.window is not None and 'framerate' in labels: labels['framerate'].set_text('%.2ffps' % self.window.get_fps()) - if not self.skip and self.renderer is not None: + if render and not self.skip and self.renderer is not None: self.renderer.render(self.game) if capture: diff --git a/pytouhou/ui/window.pxd b/pytouhou/ui/window.pxd --- a/pytouhou/ui/window.pxd +++ b/pytouhou/ui/window.pxd @@ -15,7 +15,7 @@ cdef class Runner: cdef void start(self) except * cdef void finish(self) except * - cpdef bint update(self) except? False + cpdef bint update(self, bint render) except? False cdef class Window: diff --git a/pytouhou/ui/window.pyx b/pytouhou/ui/window.pyx --- 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