Disabled actor rotation for speed
[flail.git] / game.py
blobe32465c2f2c15bfa4bcf31e3c280480f4f8f6b25
1 from pyglet.window import Window,key
2 from pyglet.gl.gl import *
4 from menu import *
8 import pyglet
12 class game (Window):
14 def __init__ (self, cfg):
15 Window.__init__ (self,
16 fullscreen = cfg['window.fullscreen'] != 'false')
18 from level import level
19 self.menu = menu (self)
20 self.lvl = level (cfg)
21 self.cfg = cfg
23 '''
24 More keypress stuff goes here. For example a key
25 to bring up the overlay, relay key events to the
26 game-in-progress, etc.
27 '''
28 def on_key_press(self,symbol,mod):
29 if symbol == key.ESCAPE:
30 self.quit_game ()
31 elif symbol == key.ASCIITILDE:
32 self.menu.active = not self.menu.active
33 elif self.menu.active:
34 self.menu.handleKey (symbol)
36 '''
37 Resize events should be propegated to the level, so it knows that the
38 view size has changed.
39 '''
41 #def on_resize(self, size, ):
42 # pass
45 '''
46 Routine to shutdown the game.
47 '''
48 def quit_game(self):
49 pyglet.app.exit ()
52 '''
53 Bring up the overlay for the game, including
54 save-game,load-game, exit, options, and anything
55 else that may be needed.
56 '''
58 def show_overlay (self):
59 self.pause_game()
61 if self.menu.active:
62 glPushMatrix ()
63 glLoadIdentity ()
65 glBindTexture (GL_TEXTURE_2D, 0)
66 glBegin (GL_TRIANGLE_STRIP)
67 glColor4d (0, 0, 0, 0.5)
69 glVertex2d (-1, -1)
70 glVertex2d ( 1, -1)
71 glVertex2d (-1, 1)
72 glVertex2d ( 1, 1)
74 glEnd ()
76 glOrtho (-self.width / 2,
77 self.width / 2,
78 -self.height / 2,
79 self.height / 2, -1, 1)
81 self.menu.render ()
83 glPopMatrix ()
85 '''
86 This should most likely disconnect the 'time' handler
87 from the 'time' events. This way the game doesn't know that
88 time is passing.
89 '''
91 def pause_game (self):
92 pass