comparison demos/shooter/run.py @ 490:939a4dc12ca1

Starting to add some comments. Cleaned up some old commented out code. The SoundManager now creates a new SoundClip rather than only creating one per FIFE SoundEmitter.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 05 May 2010 21:39:31 +0000
parents 3164715a0621
children c4168eb47a44
comparison
equal deleted inserted replaced
489:0324a3533988 490:939a4dc12ca1
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
59 self._world.showMainMenu() 58 self._world.showMainMenu()
60 evt.consume() 59 evt.consume()
61 60
62 def onCommand(self, command): 61 def onCommand(self, command):
63 self._quit = (command.getCommandType() == fife.CMD_QUIT_GAME) 62 self._quit = (command.getCommandType() == fife.CMD_QUIT_GAME)
66 65
67 class Shooter(ApplicationBase): 66 class Shooter(ApplicationBase):
68 def __init__(self): 67 def __init__(self):
69 super(Shooter,self).__init__() 68 super(Shooter,self).__init__()
70 pychan.init(self.engine, debug=False) 69 pychan.init(self.engine, debug=False)
70
71 #This is requred if you want to use modal dialog boxes
71 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) 72 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop)
72 73
73 self._world = world.World(self, self.engine) 74 self._world = world.World(self, self.engine)
74 self._listener = ApplicationListener(self.engine, self._world) 75 self._listener = ApplicationListener(self.engine, self._world)
75 76
80 self.engine.getEventManager().dispatchCommand(cmd) 81 self.engine.getEventManager().dispatchCommand(cmd)
81 82
82 def loadSettings(self): 83 def loadSettings(self):
83 """ 84 """
84 Load the settings from a python file and load them into the engine. 85 Load the settings from a python file and load them into the engine.
85 Called in the ApplicationBase constructor. 86 Called in the ApplicationBase constructor. I hard coded all the
87 settings in here to remove the complexity of loading settings from
88 an XML file which would be out of scope of this demo.
86 """ 89 """
87 90
88 engineSetting = self.engine.getSettings() 91 engineSetting = self.engine.getSettings()
89 engineSetting.setDefaultFontGlyphs(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"") 92 engineSetting.setDefaultFontGlyphs(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
90 engineSetting.setDefaultFontPath("fonts/FreeSans.ttf") 93 engineSetting.setDefaultFontPath("fonts/FreeSans.ttf")
106 109
107 def initLogging(self): 110 def initLogging(self):
108 """ 111 """
109 Initialize the LogManager. 112 Initialize the LogManager.
110 """ 113 """
111 #LogModules = list() 114
112 #LogModules.append("controller")
113 LogModules = ["controller",] 115 LogModules = ["controller",]
114 self._log = fifelog.LogManager(self.engine, 1, 0) 116 self._log = fifelog.LogManager(self.engine, 1, 0)
115 if LogModules: 117 if LogModules:
116 self._log.setVisibleModules(*LogModules) 118 self._log.setVisibleModules(*LogModules)
117 119