changeset 461:f87f686b5b59

Projectiles from enemy ships no longer destroy other enemies.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 12 Apr 2010 12:21:27 +0000
parents 5e1d6e40d19d
children c4f745a566d6
files demos/shooter/scripts/scene.py demos/shooter/scripts/ships/player.py demos/shooter/scripts/ships/shipbase.py
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/demos/shooter/scripts/scene.py	Fri Apr 09 21:42:28 2010 +0000
+++ b/demos/shooter/scripts/scene.py	Mon Apr 12 12:21:27 2010 +0000
@@ -240,7 +240,7 @@
 						self.playerHit()
 						obj.destroy()
 						
-#			self._world.renderBoundingBox(obj)
+			self._world.renderBoundingBox(obj)
 					
 		
 		
@@ -253,20 +253,20 @@
 				#cant get hit by your own bullet
 				if p.owner != o:
 					if p.boundingbox.intersects(o.boundingbox):
-						if o != self._player:
+						if o != self._player and p.owner.isplayer:
 							self._player.applyScore(100)
 							p.destroy()
 							o.destroy()
 							#TODO:  the destroy functions should spawn an explosion
 							#and also destroy the instance and remove itself from the scene
 							#self.removeObjectFromScene(o)
-						else:
+						elif o == self._player:
 							#player got hit by a projectile
 							if not self._player.invulnerable:
 								p.destroy()
 								self.playerHit()
 			
-#			self._world.renderBoundingBox(p)
+			self._world.renderBoundingBox(p)
 							
 			
 			#build a list of projectiles to remove (ttl expired)
--- a/demos/shooter/scripts/ships/player.py	Fri Apr 09 21:42:28 2010 +0000
+++ b/demos/shooter/scripts/ships/player.py	Mon Apr 12 12:21:27 2010 +0000
@@ -42,6 +42,8 @@
 		
 		self._lives = 3
 		self._invulnerable = False
+		
+		self._isplayer = True
 	
 	def init(self):
 		self._lives = 3
--- a/demos/shooter/scripts/ships/shipbase.py	Fri Apr 09 21:42:28 2010 +0000
+++ b/demos/shooter/scripts/ships/shipbase.py	Mon Apr 12 12:21:27 2010 +0000
@@ -40,6 +40,8 @@
 		
 		#1 = on, 0 = invisible (off)
 		self._flashstate = 1
+		
+		self._isplayer = False
 	
 	def _setWeapon(self, weapon):
 		self._weapon = weapon
@@ -85,6 +87,10 @@
 					self._flashnumber -= 1
 	
 		super(Ship, self).update()
+		
+	def _isPlayer(self):
+		return self._isplayer
 	
+	isplayer = property(_isPlayer)
 	weapon = property(_getWeapon, _setWeapon)
 	
\ No newline at end of file