Mercurial > touhou
diff pytouhou/ui/gamerunner.pyx @ 592:19d930f9e3f0
Add the screenshot feature, using P or Home like the original game.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 23 Apr 2014 19:19:32 +0200 |
parents | 00f228b57840 |
children | 12756994a92c |
line wrap: on
line diff
--- a/pytouhou/ui/gamerunner.pyx +++ b/pytouhou/ui/gamerunner.pyx @@ -108,8 +108,15 @@ cdef class GameRunner(Runner): self.renderer.start(self.common) + cdef void capture(self) except *: + if self.renderer is not None: + filename = 'screenshot/frame%06d.ppm' % self.game.frame + self.renderer.capture(filename, self.width, self.height) + + cpdef bint update(self) except? False: cdef long keystate + capture = False if self.background is not None: self.background.update(self.game.frame) @@ -119,6 +126,8 @@ cdef class GameRunner(Runner): scancode = event[1] if scancode == sdl.SCANCODE_ESCAPE: return False #TODO: implement the pause. + elif scancode == sdl.SCANCODE_P or scancode == sdl.SCANCODE_HOME: + capture = True elif type_ == sdl.QUIT: return False elif type_ == sdl.WINDOWEVENT: @@ -172,4 +181,7 @@ cdef class GameRunner(Runner): if not self.skip and self.renderer is not None: self.renderer.render(self.game) + if capture: + self.capture() + return True