Mercurial > fife-parpg
comparison demos/shooter/run.py @ 455:e686b82d93d0
Added the ability to pause the game.
Added the main menu.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 07 Apr 2010 19:37:42 +0000 |
parents | 2046a1f2f5f2 |
children | be035dff788a |
comparison
equal
deleted
inserted
replaced
454:bd7e8f708adf | 455:e686b82d93d0 |
---|---|
53 def keyPressed(self, evt): | 53 def keyPressed(self, evt): |
54 keyval = evt.getKey().getValue() | 54 keyval = evt.getKey().getValue() |
55 keystr = evt.getKey().getAsString().lower() | 55 keystr = evt.getKey().getAsString().lower() |
56 consumed = False | 56 consumed = False |
57 if keyval == fife.Key.ESCAPE: | 57 if keyval == fife.Key.ESCAPE: |
58 self.quit = True | 58 #self.quit = True |
59 self.world.showMainMenu() | |
59 evt.consume() | 60 evt.consume() |
60 | 61 |
61 def onCommand(self, command): | 62 def onCommand(self, command): |
62 self.quit = (command.getCommandType() == fife.CMD_QUIT_GAME) | 63 self.quit = (command.getCommandType() == fife.CMD_QUIT_GAME) |
63 if self.quit: | 64 if self.quit: |
64 command.consume() | 65 command.consume() |
65 | 66 |
66 class Tutorial(ApplicationBase): | 67 class Shooter(ApplicationBase): |
67 def __init__(self): | 68 def __init__(self): |
68 super(Tutorial,self).__init__() | 69 super(Shooter,self).__init__() |
69 pychan.init(self.engine, debug=False) | 70 pychan.init(self.engine, debug=False) |
70 self.world = world.World(self.engine) | 71 |
72 self.world = world.World(self, self.engine) | |
71 self.listener = ApplicationListener(self.engine, self.world) | 73 self.listener = ApplicationListener(self.engine, self.world) |
72 self.world.load("maps/shooter_map1.xml") | |
73 | 74 |
75 def requestQuit(self): | |
76 self.breakRequested = True | |
77 | |
74 def loadSettings(self): | 78 def loadSettings(self): |
75 """ | 79 """ |
76 Load the settings from a python file and load them into the engine. | 80 Load the settings from a python file and load them into the engine. |
77 Called in the ApplicationBase constructor. | 81 Called in the ApplicationBase constructor. |
78 """ | 82 """ |
115 self.breakRequested = True | 119 self.breakRequested = True |
116 else: | 120 else: |
117 self.world.pump() | 121 self.world.pump() |
118 | 122 |
119 def main(): | 123 def main(): |
120 app = Tutorial() | 124 app = Shooter() |
121 app.run() | 125 app.run() |
122 | 126 |
123 | 127 |
124 if __name__ == '__main__': | 128 if __name__ == '__main__': |
125 main() | 129 main() |