Mercurial > touhou
annotate pytouhou/ui/gamerunner.py @ 224:9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 19 Dec 2011 20:29:30 +0100 |
parents | ee6dfd14a785 |
children | 2d35565b5608 |
rev | line source |
---|---|
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
2 ## |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
4 ## |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
8 ## |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
13 ## |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
14 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
15 import pyglet |
146
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
16 import traceback |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
17 |
203
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
18 from pyglet.gl import (glMatrixMode, glLoadIdentity, glEnable, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
19 glHint, glEnableClientState, glViewport, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
20 gluPerspective, gluLookAt, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
21 GL_MODELVIEW, GL_PROJECTION, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
22 GL_TEXTURE_2D, GL_BLEND, GL_FOG, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
23 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, |
df8b2ab54639
Make pylint slightly happier (and code analysis easier)
Thibaut Girka <thib@sitedethib.com>
parents:
188
diff
changeset
|
24 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY) |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
25 |
224
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
26 from pytouhou.utils.helpers import get_logger |
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
27 |
205
ee6dfd14a785
Rename pytouhou.opengl to pytouhou.ui, makes much more sense that way.
Thibaut Girka <thib@sitedethib.com>
parents:
203
diff
changeset
|
28 from .gamerenderer import GameRenderer |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
29 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
30 |
224
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
31 logger = get_logger(__name__) |
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
32 |
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
33 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
34 class GameRunner(pyglet.window.Window, GameRenderer): |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
35 def __init__(self, resource_loader, game=None, background=None, replay=None): |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
36 GameRenderer.__init__(self, resource_loader, game, background) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
37 pyglet.window.Window.__init__(self, caption='PyTouhou', resizable=False) |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
38 self.replay_level = None |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
39 if not replay or not replay.levels[game.stage-1]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
40 self.keys = pyglet.window.key.KeyStateHandler() |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
41 self.push_handlers(self.keys) |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
42 else: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
43 self.keys = 0 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
44 self.replay_level = replay.levels[game.stage-1] |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
45 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
46 self.fps_display = pyglet.clock.ClockDisplay() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
47 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
48 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
49 def start(self, width=384, height=448): |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
50 self.set_size(width, height) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
51 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
52 # Initialize OpenGL |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
53 glMatrixMode(GL_PROJECTION) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
54 glLoadIdentity() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
55 gluPerspective(30, float(width)/float(height), |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
56 101010101./2010101., 101010101./10101.) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
57 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
58 glEnable(GL_BLEND) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
59 glEnable(GL_TEXTURE_2D) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
60 glEnable(GL_FOG) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
61 glHint(GL_FOG_HINT, GL_NICEST) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
62 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
63 glEnableClientState(GL_COLOR_ARRAY) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
64 glEnableClientState(GL_VERTEX_ARRAY) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
65 glEnableClientState(GL_TEXTURE_COORD_ARRAY) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
66 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
67 # Use our own loop to ensure 60 (for now, 120) fps |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
68 pyglet.clock.set_fps_limit(120) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
69 while not self.has_exit: |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
70 pyglet.clock.tick() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
71 self.dispatch_events() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
72 self.update() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
73 self.on_draw() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
74 self.flip() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
75 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
76 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
77 def on_resize(self, width, height): |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
78 glViewport(0, 0, width, height) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
79 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
80 |
146
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
81 def _event_text_symbol(self, ev): |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
82 # XXX: Ugly workaround to a pyglet bug on X11 |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
83 #TODO: fix that bug in pyglet |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
84 try: |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
85 return pyglet.window.Window._event_text_symbol(self, ev) |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
86 except Exception as exc: |
224
9bb26dbb8438
Remove useless and occasionally problematic (think about non-utf8 terminals) print calls.
Thibaut Girka <thib@sitedethib.com>
parents:
205
diff
changeset
|
87 logger.warn('Pyglet error: %s', traceback.format_exc(exc)) |
146
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
88 return None, None |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
89 |
96c30ffd9b87
Evil workaround to pyglet's X11 backend
Thibaut Girka <thib@sitedethib.com>
parents:
131
diff
changeset
|
90 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
91 def on_key_press(self, symbol, modifiers): |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
92 if symbol == pyglet.window.key.ESCAPE: |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
93 self.has_exit = True |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
94 # XXX: Fullscreen will be enabled the day pyglet stops sucking |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
95 elif symbol == pyglet.window.key.F11: |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
96 self.set_fullscreen(not self.fullscreen) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
97 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
98 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
99 def update(self): |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
100 if self.background: |
151
5cf927cbd9c5
Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents:
146
diff
changeset
|
101 self.background.update(self.game.frame) |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
102 if self.game: |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
103 if not self.replay_level: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
104 #TODO: allow user settings |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
105 keystate = 0 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
106 if self.keys[pyglet.window.key.W]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
107 keystate |= 1 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
108 if self.keys[pyglet.window.key.X]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
109 keystate |= 2 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
110 #TODO: on some configurations, LSHIFT is Shift_L when pressed |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
111 # and ISO_Prev_Group when released, confusing the hell out of pyglet |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
112 # and leading to a always-on LSHIFT... |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
113 if self.keys[pyglet.window.key.LSHIFT]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
114 keystate |= 4 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
115 if self.keys[pyglet.window.key.UP]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
116 keystate |= 16 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
117 if self.keys[pyglet.window.key.DOWN]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
118 keystate |= 32 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
119 if self.keys[pyglet.window.key.LEFT]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
120 keystate |= 64 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
121 if self.keys[pyglet.window.key.RIGHT]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
122 keystate |= 128 |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
123 if self.keys[pyglet.window.key.LCTRL]: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
124 keystate |= 256 |
188
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
125 self.game.run_iter(keystate) |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
126 else: |
188
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
127 keystate = 0 |
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
128 for frame, _keystate, unknown in self.replay_level.keys: |
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
129 if self.game.frame < frame: |
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
130 break |
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
131 else: |
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
132 keystate = _keystate |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
158
diff
changeset
|
133 |
188
008f90ebfdc0
Fix replay handling and add support for encrypted replays
Thibaut Girka <thib@sitedethib.com>
parents:
187
diff
changeset
|
134 self.game.run_iter(keystate) |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
135 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
136 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
137 def on_draw(self): |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
138 GameRenderer.render(self) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
139 |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
140 #TODO |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
141 glMatrixMode(GL_MODELVIEW) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
142 glLoadIdentity() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
143 gluLookAt(192., 224., 835.979370, |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
144 192, 224., 0., 0., 1., 0.) |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
145 self.fps_display.draw() |
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
146 |