Mercurial > fife-parpg
comparison demos/rpg/scripts/gamecontroller.py @ 543:cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 02 Jun 2010 21:43:03 +0000 |
parents | 2e739ae9a8bc |
children | bc7e3c3122d7 |
comparison
equal
deleted
inserted
replaced
542:67f6f3538e88 | 543:cb7ec12214a9 |
---|---|
22 # Free Software Foundation, Inc., | 22 # Free Software Foundation, Inc., |
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 # #################################################################### | 24 # #################################################################### |
25 # This is the rio de hola client for FIFE. | 25 # This is the rio de hola client for FIFE. |
26 | 26 |
27 import sys, os, re, math, random, shutil | 27 import sys, os, re, math, random, shutil, glob |
28 | 28 |
29 from fife import fife | 29 from fife import fife |
30 | 30 |
31 from fife.extensions.soundmanager import SoundManager | 31 from fife.extensions.soundmanager import SoundManager |
32 from fife.extensions.loaders import loadImportFile | 32 from fife.extensions.loaders import loadImportFile |
256 return result | 256 return result |
257 | 257 |
258 def newGame(self): | 258 def newGame(self): |
259 self._guicontroller.hideMainMenu() | 259 self._guicontroller.hideMainMenu() |
260 | 260 |
261 for filename in glob.glob("saves\*.xml"): | |
262 os.remove(filename) | |
263 | |
261 mapname = self._settings.get("RPG", "TownMapFile", "town") | 264 mapname = self._settings.get("RPG", "TownMapFile", "town") |
262 self.loadMap(mapname) | 265 self.loadMap(mapname) |
263 | 266 |
264 | 267 |
265 def loadMap(self, mapname): | 268 def loadMap(self, mapname): |
271 if self._scene: | 274 if self._scene: |
272 self._scene.destroyScene() | 275 self._scene.destroyScene() |
273 self._scene = None | 276 self._scene = None |
274 | 277 |
275 self._scene = Scene(self) | 278 self._scene = Scene(self) |
276 self._scene.createScene("maps/" + mapname + ".xml") | 279 |
280 self._scene.createScene(mapname) | |
277 | 281 |
278 self._instancerenderer = fife.InstanceRenderer.getInstance(self._scene.cameras[self._settings.get("RPG", "DefaultCameraName", "camera1")]) | 282 self._instancerenderer = fife.InstanceRenderer.getInstance(self._scene.cameras[self._settings.get("RPG", "DefaultCameraName", "camera1")]) |
279 self._floatingtextrenderer = fife.FloatingTextRenderer.getInstance(self._scene.cameras[self._settings.get("RPG", "DefaultCameraName", "camera1")]) | 283 self._floatingtextrenderer = fife.FloatingTextRenderer.getInstance(self._scene.cameras[self._settings.get("RPG", "DefaultCameraName", "camera1")]) |
280 self._floatingtextrenderer.addActiveLayer(self._scene.actorlayer) | 284 self._floatingtextrenderer.addActiveLayer(self._scene.actorlayer) |
281 | 285 |
283 self._listener.attach() | 287 self._listener.attach() |
284 | 288 |
285 def switchMap(self, newmapname): | 289 def switchMap(self, newmapname): |
286 self._switchmaprequested = True | 290 self._switchmaprequested = True |
287 self._newmap = newmapname | 291 self._newmap = newmapname |
292 | |
293 self._scene.serialize() | |
288 | 294 |
289 def endGame(self): | 295 def endGame(self): |
290 if self._scene: | 296 if self._scene: |
297 self._scene.serialize() | |
298 | |
291 self._listener.detach() | 299 self._listener.detach() |
292 self._scene.destroyScene() | 300 self._scene.destroyScene() |
293 self._scene = None | 301 self._scene = None |
294 self._instancerenderer = None | 302 self._instancerenderer = None |
295 self._floatingtextrenderer = None | 303 self._floatingtextrenderer = None |