diff demos/shooter/scripts/weapons.py @ 447:64676ea55472

Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 31 Mar 2010 21:13:07 +0000
parents 2046a1f2f5f2
children 5e2ec84902a7
line wrap: on
line diff
--- a/demos/shooter/scripts/weapons.py	Wed Mar 31 15:40:00 2010 +0000
+++ b/demos/shooter/scripts/weapons.py	Wed Mar 31 21:13:07 2010 +0000
@@ -35,6 +35,9 @@
 		self._ttl = timeToLive
 		self._starttime = 0
 		
+		self._xscale = self._layer.getCellGrid().getXScale()
+		self._yscale = self._layer.getCellGrid().getYScale()
+		
 	def create(self, location):
 		self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet")
 		fife.InstanceVisual.create(self._instance)
@@ -42,6 +45,8 @@
 	def run(self, velocity, location, time):
 		if not self._running:
 			self._velocity = velocity
+			self._velocity.x /= self._xscale
+			self._velocity.y /= self._yscale
 		
 			self.create(location)
 			self._running = True
@@ -89,11 +94,12 @@
 		self._ship = ship
 		self._firerate = firerate
 		self._lastfired = 0
+		self._projectileVelocity = fife.DoublePoint(0.075,0)
 		
 	def fire(self, curtime):
 		if (curtime - self._lastfired) > self._firerate:
 			pjctl = Projectile(self._model, "bullet1", self._layer, 2000 )
-			pjctl.run(fife.DoublePoint(0.075,0), self._ship.location, curtime)
+			pjctl.run(fife.DoublePoint(self._projectileVelocity.x,self._projectileVelocity.y), self._ship.location, curtime)
 			self._lastfired = curtime
 			return pjctl