Mercurial > touhou
comparison pytouhou/ui/gamerunner.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 | 6e733ed817bd |
children | 36bc577b2392 |
comparison
equal
deleted
inserted
replaced
462:a71b912b45b7 | 463:11708a1d0a1a |
---|---|
12 ## GNU General Public License for more details. | 12 ## GNU General Public License for more details. |
13 ## | 13 ## |
14 | 14 |
15 from pytouhou.lib cimport sdl | 15 from pytouhou.lib cimport sdl |
16 | 16 |
17 from .window cimport Window | 17 from .window cimport Window, Runner |
18 from .gamerenderer cimport GameRenderer | 18 from .gamerenderer cimport GameRenderer |
19 from .music import MusicPlayer, SFXPlayer, NullPlayer | 19 from .music import MusicPlayer, SFXPlayer, NullPlayer |
20 | 20 |
21 | 21 |
22 cdef class GameRunner: | 22 cdef class GameRunner(Runner): |
23 cdef object game, background | 23 cdef object game, background |
24 cdef GameRenderer renderer | 24 cdef GameRenderer renderer |
25 cdef Window window | 25 cdef Window window |
26 cdef object replay_level, save_keystates | 26 cdef object replay_level, save_keystates |
27 cdef long width, height, keystate | 27 cdef long keystate |
28 cdef bint skip, use_fixed_pipeline | 28 cdef bint skip, use_fixed_pipeline |
29 | 29 |
30 def __init__(self, window, resource_loader, bint skip=False): | 30 def __init__(self, window, resource_loader, bint skip=False): |
31 self.use_fixed_pipeline = window.use_fixed_pipeline #XXX | 31 self.use_fixed_pipeline = window.use_fixed_pipeline #XXX |
32 | 32 |
73 else: | 73 else: |
74 self.replay_level = replay.levels[self.game.stage-1] | 74 self.replay_level = replay.levels[self.game.stage-1] |
75 self.keys = self.replay_level.iter_keystates() | 75 self.keys = self.replay_level.iter_keystates() |
76 | 76 |
77 | 77 |
78 def start(self): | 78 cdef void start(self) except *: |
79 cdef long width, height | 79 cdef long width, height |
80 width = self.game.interface.width if self.game is not None else 640 | 80 width = self.game.interface.width if self.game is not None else 640 |
81 height = self.game.interface.height if self.game is not None else 480 | 81 height = self.game.interface.height if self.game is not None else 480 |
82 if width != self.width or height != self.height: | 82 if width != self.width or height != self.height: |
83 self.window.set_size(width, height) | 83 self.window.set_size(width, height) |
84 | 84 |
85 self.renderer.start(self.game) | 85 self.renderer.start(self.game) |
86 | 86 |
87 | 87 |
88 def finish(self): | 88 cdef bint update(self) except *: |
89 #TODO: actually clean after buffers are not needed anymore. | |
90 #if not self.use_fixed_pipeline: | |
91 # vbo_array = (c_uint * 2)(self.vbo, self.back_vbo) | |
92 # glDeleteBuffers(2, vbo_array) | |
93 pass | |
94 | |
95 | |
96 def update(self): | |
97 cdef long keystate | 89 cdef long keystate |
98 | 90 |
99 if self.background: | 91 if self.background: |
100 self.background.update(self.game.frame) | 92 self.background.update(self.game.frame) |
101 for event in sdl.poll_events(): | 93 for event in sdl.poll_events(): |