Mercurial > fife-parpg
changeset 537:764510a6d2f9
Added the move command.
Updated the settings-dist.xml file that changes the camera zoom to 1 and adds the script module to the log.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 31 May 2010 21:37:10 +0000 |
parents | 1afe46247ab1 |
children | 00aa20dc8b7f |
files | demos/rpg/misc/help.txt demos/rpg/scripts/gamecontroller.py demos/rpg/scripts/scene.py demos/rpg/settings-dist.xml |
diffstat | 4 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/demos/rpg/misc/help.txt Mon May 31 20:25:46 2010 +0000 +++ b/demos/rpg/misc/help.txt Mon May 31 21:37:10 2010 +0000 @@ -1,4 +1,5 @@ eval - Evaluate a python expression exit, quit - Quit the game help - Displays this message +move - Moves an object spawn - Spawns an item or actor
--- a/demos/rpg/scripts/gamecontroller.py Mon May 31 20:25:46 2010 +0000 +++ b/demos/rpg/scripts/gamecontroller.py Mon May 31 21:37:10 2010 +0000 @@ -212,7 +212,7 @@ cmd.append(arg) if cmd[0] == "spawn": - result = "Usage: spawn [item|actor] [id] [posx] [posy]" + result = "Usage: spawn [item|actor] [object id] [posx] [posy]" if len(cmd) != 5: return result else: @@ -230,9 +230,22 @@ if obj: try: self._scene.addObjectToScene(obj) + obj.position = (float(cmd[3]), float(cmd[4])) result = "--OK--" except ObjectAlreadyInSceneError, e: result = "Error: [" + cmd[2] + "] is already on the scene." + + elif cmd[0] == "move": + result = "Usage: move [object id] [posx] [posy]" + if len(cmd) != 4: + return result + else: + obj = self._scene.getObject(cmd[1]) + if obj: + obj.position = (float(cmd[2]), float(cmd[3])) + result = "--OK--" + else: + result = "Error: [" + cmd[1] + "] does not exist on the scene." return result
--- a/demos/rpg/scripts/scene.py Mon May 31 20:25:46 2010 +0000 +++ b/demos/rpg/scripts/scene.py Mon May 31 21:37:10 2010 +0000 @@ -220,6 +220,12 @@ else: obj.destroy() raise ObjectAlreadyInSceneError + + def getObject(self, objid): + if self._objectlist.has_key(objid): + return self._objectlist[objid] + else: + return None def removeObjectFromScene(self, obj): obj.destroy()
--- a/demos/rpg/settings-dist.xml Mon May 31 20:25:46 2010 +0000 +++ b/demos/rpg/settings-dist.xml Mon May 31 21:37:10 2010 +0000 @@ -14,7 +14,7 @@ <Setting name="Font" type="str"> fonts/FreeSans.ttf </Setting> <Setting name="FontGlyphs" strip="0" type="str"> abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"</Setting> <Setting name="DefaultFontSize" type="int"> 16 </Setting> - <Setting name="LogModules" type="list"> controller </Setting> + <Setting name="LogModules" type="list"> controller ; script </Setting> <Setting name="PychanDebug" type="bool"> False </Setting> <Setting name="LogToPrompt" type="int"> 1 </Setting> <Setting name="UsePsyco" type="bool"> False </Setting> @@ -27,7 +27,7 @@ <Setting name="AllObjectFile" type="str"> maps/allobjects.xml </Setting> <Setting name="Level1MapFile" type="str"> maps/level1.xml </Setting> <Setting name="DefaultCameraName" type="str"> camera1 </Setting> - <Setting name="DefaultZoom" type="float"> 2.0 </Setting> + <Setting name="DefaultZoom" type="float"> 1.0 </Setting> <Setting name="ObjectNamespace" type="str"> http://www.fifengine.de/xml/rpg </Setting> <Setting name="ActorLayer" type="str"> actor_layer </Setting> <Setting name="ItemLayer" type="str"> item_layer </Setting>