diff demos/shooter/scripts/ships/shipbase.py @ 467:4d0aa75a82f1

Added damage so some enemies take more than one hit to destroy. Added the boss at the end of the level. For some reason the high score dialog box that appears after the level is completed causes a crash. Still looking into this one.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 14 Apr 2010 16:22:36 +0000
parents ac0f62a07a3e
children 7a79dc2a0592
line wrap: on
line diff
--- a/demos/shooter/scripts/ships/shipbase.py	Tue Apr 13 21:30:51 2010 +0000
+++ b/demos/shooter/scripts/ships/shipbase.py	Wed Apr 14 16:22:36 2010 +0000
@@ -48,6 +48,9 @@
 		self._flashing = False
 		
 		self._isplayer = False
+		
+		self._hitpoints = 0
+		self._scorevalue = 0
 	
 	def _setWeapon(self, weapon):
 		self._weapon = weapon
@@ -66,6 +69,11 @@
 		
 		return None
 		
+	def applyHit(self, hp):
+		self._hitpoints -= hp
+		if self._hitpoints <= 0:
+			self.destroy()
+		
 	def destroy(self):
 		if self._running:
 			self._instance.act('explode', self._instance.getFacingLocation())
@@ -74,6 +82,20 @@
 	def _isPlayer(self):
 		return self._isplayer
 	
+	
+	def _getHitPoints(self):
+		return self._hitpoints
+		
+	def _setHitPoints(self, hp):
+		self._hitpoints = hp
+		
+	def _getScoreValue(self):
+		return self._scorevalue
+	
+	def _setScoreValue(self, value):
+		self._scorevalue = value
+	
 	isplayer = property(_isPlayer)
 	weapon = property(_getWeapon, _setWeapon)
-	
\ No newline at end of file
+	hitpoints = property(_getHitPoints, _setHitPoints)
+	scorevalue = property(_getScoreValue, _setScoreValue)
\ No newline at end of file