diff demos/shooter/scripts/ships/player.py @ 451:f463ab431cc0

Movement shouldn't be dependent on framerate anymore. Some minor tweaks.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 01 Apr 2010 21:14:23 +0000
parents ba6817013343
children cf53848fb187
line wrap: on
line diff
--- a/demos/shooter/scripts/ships/player.py	Thu Apr 01 19:26:56 2010 +0000
+++ b/demos/shooter/scripts/ships/player.py	Thu Apr 01 21:14:23 2010 +0000
@@ -29,7 +29,7 @@
 class Player(Ship):
 	def __init__(self, model, playerName, layer):
 		super(Player, self).__init__(model, playerName, layer)
-		self._bounds = Rect(-100,-100,200,200)
+
 		self._score = 0
 	
 	def _getScore(self):
@@ -44,20 +44,20 @@
 		oldpos = self.location
 		
 		if keystate['UP']:
-			self.applyThrust(fife.DoublePoint(0,-0.075), timedelta)
+			self.applyThrust(fife.DoublePoint(0,-0.75), timedelta)
 			key = True
 		if keystate['DOWN']:
-			self.applyThrust(fife.DoublePoint(0,0.075), timedelta)
+			self.applyThrust(fife.DoublePoint(0,0.75), timedelta)
 			key = True
 		if keystate['LEFT']:
-			self.applyThrust(fife.DoublePoint(-0.075,0), timedelta)
+			self.applyThrust(fife.DoublePoint(-0.75,0), timedelta)
 			key = True
 		if keystate['RIGHT']:
-			self.applyThrust(fife.DoublePoint(0.075,0), timedelta)
+			self.applyThrust(fife.DoublePoint(0.75,0), timedelta)
 			key = True
 			
 		if not key and self._velocity.length() > 0:
-			self.applyBrake(0.075, timedelta)
+			self.applyBrake(0.75, timedelta)
 		
 		super(Player, self).update(timedelta)
 		
@@ -69,28 +69,21 @@
 		camrect = Rect(topleft.x, topleft.y, bottomright.x - topleft.x, bottomright.y - topleft.y)
 	
 		#player bounding box
-		#TODO: make this configurable
 		xscale = self._layer.getCellGrid().getXScale()
 		yscale = self._layer.getCellGrid().getYScale()
-		pos = self.location.getExactLayerCoordinates()
-		bbox = Rect()
-		bbox.x = pos.x*xscale - 0.175
-		bbox.y = pos.y*yscale - 0.175
-		bbox.w = 0.25
-		bbox.h = 0.25
+
 
 		#add the padding to the edge
-		camrect.x += bbox.w
-		camrect.y += bbox.h
-		camrect.w -= 2*bbox.w
-		camrect.h -= 2*bbox.h
-
+		camrect.x += self._boundingBox.w
+		camrect.y += self._boundingBox.h
+		camrect.w -= 2*self._boundingBox.w
+		camrect.h -= 2*self._boundingBox.h
 		
-		if not bbox.intersects(camrect):
-			if (bbox.x + bbox.w) < camrect.x:
+		if not self._boundingBox.intersects(camrect):
+			if (self._boundingBox.x + self._boundingBox.w) < camrect.x:
 				#pos.x = (bbox.x + bbox.w/2 + 0.1) / xscale
 				#oldpos.setExactLayerCoordinates(pos)
-				self._velocity.x = (timedelta * 0.001) / xscale
+				self._velocity.x = (timedelta * 0.01) / xscale
 			
 #			elif (bbox.y + bbox.h) < camrect.y or (bbox.y - bbox.h) > camrect.y:
 #				pos.x += self._velocity.x * (timedelta/1000.0)