diff demos/rpg/scripts/gamecontroller.py @ 524:6037f79b0dcf

Multiple quests now work. Added the item layer. Made movement more like diablo by allowing you to hold and drag the left mouse button. All objects are now loaded from a separate "allobjects" file. Specific item attributes are loaded from the map objects file (like position). This allows for the possibility of multiple instances using the same FIFE model.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 27 May 2010 21:11:37 +0000
parents d01eb65b2726
children 796d49ab9380
line wrap: on
line diff
--- a/demos/rpg/scripts/gamecontroller.py	Thu May 27 18:29:20 2010 +0000
+++ b/demos/rpg/scripts/gamecontroller.py	Thu May 27 21:11:37 2010 +0000
@@ -66,6 +66,8 @@
 		
 		self._attached = False
 		
+		self._lastmousepos = (0.0,0.0)
+		
 	def attach(self):
 		if not self._attached:
 			self._gamecontroller.keystate.reset()
@@ -85,7 +87,9 @@
 			return
 
 		clickpoint = fife.ScreenPoint(event.getX(), event.getY())
+
 		if (event.getButton() == fife.MouseEvent.LEFT):
+			self._lastmousepos = (clickpoint.x, clickpoint.y)
 			self._gamecontroller.scene.player.walk( self._gamecontroller.scene.getLocationAt(clickpoint) )
 			instances = self._gamecontroller.scene.getInstancesAt(clickpoint)
 			if instances:
@@ -133,7 +137,15 @@
 		pass
 		
 	def mouseDragged(self, event):
-		pass
+		if event.isConsumedByWidgets():
+			return
+
+		clickpoint = fife.ScreenPoint(event.getX(), event.getY())
+		if (event.getButton() == fife.MouseEvent.LEFT):
+			if clickpoint.x > self._lastmousepos[0] + 5 or  clickpoint.x < self._lastmousepos[0] - 5 or clickpoint.y > self._lastmousepos[1] + 5 or clickpoint.y < self._lastmousepos[1] - 5:
+				self._gamecontroller.scene.player.walk( self._gamecontroller.scene.getLocationAt(clickpoint) )
+
+			self._lastmousepos = (clickpoint.x, clickpoint.y)
 		
 	def keyPressed(self, event):
 		keyval = event.getKey().getValue()
@@ -187,6 +199,7 @@
 			self._scene = None
 			
 		loadImportFile("objects/actors/player/warrior/object.xml", self._engine)
+		loadImportFile("objects/items/goldstack/object.xml", self._engine)
 		
 		self._scene = Scene(self)
 		self._scene.createScene(self._settings.get("RPG", "TownMapFile", "maps/town.xml"))