Mercurial > fife-parpg
comparison demos/shooter/run.py @ 472:3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
Added rotatePoint function.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 16 Apr 2010 21:44:18 +0000 |
parents | 4e58dab2fcdc |
children | 939a4dc12ca1 |
comparison
equal
deleted
inserted
replaced
471:7a79dc2a0592 | 472:3164715a0621 |
---|---|
41 from fife.extensions.pychan import widgets | 41 from fife.extensions.pychan import widgets |
42 | 42 |
43 class ApplicationListener(eventlistenerbase.EventListenerBase): | 43 class ApplicationListener(eventlistenerbase.EventListenerBase): |
44 def __init__(self, engine, world): | 44 def __init__(self, engine, world): |
45 super(ApplicationListener, self).__init__(engine,regKeys=True,regCmd=True, regMouse=False, regConsole=True, regWidget=True) | 45 super(ApplicationListener, self).__init__(engine,regKeys=True,regCmd=True, regMouse=False, regConsole=True, regWidget=True) |
46 self.engine = engine | 46 self._engine = engine |
47 self.world = world | 47 self._world = world |
48 engine.getEventManager().setNonConsumableKeys([ | 48 engine.getEventManager().setNonConsumableKeys([ |
49 fife.Key.ESCAPE,]) | 49 fife.Key.ESCAPE,]) |
50 | 50 |
51 self.quit = False | 51 self._quit = False |
52 | 52 |
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 self._world.showMainMenu() |
60 evt.consume() | 60 evt.consume() |
61 | 61 |
62 def onCommand(self, command): | 62 def onCommand(self, command): |
63 self.quit = (command.getCommandType() == fife.CMD_QUIT_GAME) | 63 self._quit = (command.getCommandType() == fife.CMD_QUIT_GAME) |
64 if self.quit: | 64 if self._quit: |
65 command.consume() | 65 command.consume() |
66 | 66 |
67 class Shooter(ApplicationBase): | 67 class Shooter(ApplicationBase): |
68 def __init__(self): | 68 def __init__(self): |
69 super(Shooter,self).__init__() | 69 super(Shooter,self).__init__() |
70 pychan.init(self.engine, debug=False) | 70 pychan.init(self.engine, debug=False) |
71 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) | 71 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) |
72 | 72 |
73 self.world = world.World(self, self.engine) | 73 self._world = world.World(self, self.engine) |
74 self.listener = ApplicationListener(self.engine, self.world) | 74 self._listener = ApplicationListener(self.engine, self._world) |
75 | 75 |
76 def requestQuit(self): | 76 def requestQuit(self): |
77 cmd = fife.Command() | 77 cmd = fife.Command() |
78 cmd.setSource(None) | 78 cmd.setSource(None) |
79 cmd.setCommandType(fife.CMD_QUIT_GAME) | 79 cmd.setCommandType(fife.CMD_QUIT_GAME) |
109 Initialize the LogManager. | 109 Initialize the LogManager. |
110 """ | 110 """ |
111 #LogModules = list() | 111 #LogModules = list() |
112 #LogModules.append("controller") | 112 #LogModules.append("controller") |
113 LogModules = ["controller",] | 113 LogModules = ["controller",] |
114 self.log = fifelog.LogManager(self.engine, 1, 0) | 114 self._log = fifelog.LogManager(self.engine, 1, 0) |
115 if LogModules: | 115 if LogModules: |
116 self.log.setVisibleModules(*LogModules) | 116 self._log.setVisibleModules(*LogModules) |
117 | 117 |
118 def createListener(self): | 118 def createListener(self): |
119 pass # already created in constructor | 119 pass # already created in constructor |
120 | 120 |
121 def _pump(self): | 121 def _pump(self): |
122 if self.listener.quit: | 122 if self._listener._quit: |
123 self.breakRequested = True | 123 self.breakRequested = True |
124 else: | 124 else: |
125 self.world.pump() | 125 self._world.pump() |
126 | 126 |
127 def main(): | 127 def main(): |
128 app = Shooter() | 128 app = Shooter() |
129 app.run() | 129 app.run() |
130 | 130 |