comparison 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
comparison
equal deleted inserted replaced
466:716d44ba42df 467:4d0aa75a82f1
46 46
47 self._flashnumber = 0 47 self._flashnumber = 0
48 self._flashing = False 48 self._flashing = False
49 49
50 self._isplayer = False 50 self._isplayer = False
51
52 self._hitpoints = 0
53 self._scorevalue = 0
51 54
52 def _setWeapon(self, weapon): 55 def _setWeapon(self, weapon):
53 self._weapon = weapon 56 self._weapon = weapon
54 57
55 def _getWeapon(self): 58 def _getWeapon(self):
64 if self._weapon: 67 if self._weapon:
65 return self._weapon.fire(direction) 68 return self._weapon.fire(direction)
66 69
67 return None 70 return None
68 71
72 def applyHit(self, hp):
73 self._hitpoints -= hp
74 if self._hitpoints <= 0:
75 self.destroy()
76
69 def destroy(self): 77 def destroy(self):
70 if self._running: 78 if self._running:
71 self._instance.act('explode', self._instance.getFacingLocation()) 79 self._instance.act('explode', self._instance.getFacingLocation())
72 super(Ship, self).destroy() 80 super(Ship, self).destroy()
73 81
74 def _isPlayer(self): 82 def _isPlayer(self):
75 return self._isplayer 83 return self._isplayer
76 84
85
86 def _getHitPoints(self):
87 return self._hitpoints
88
89 def _setHitPoints(self, hp):
90 self._hitpoints = hp
91
92 def _getScoreValue(self):
93 return self._scorevalue
94
95 def _setScoreValue(self, value):
96 self._scorevalue = value
97
77 isplayer = property(_isPlayer) 98 isplayer = property(_isPlayer)
78 weapon = property(_getWeapon, _setWeapon) 99 weapon = property(_getWeapon, _setWeapon)
79 100 hitpoints = property(_getHitPoints, _setHitPoints)
101 scorevalue = property(_getScoreValue, _setScoreValue)