comparison demos/shooter/scripts/weapons.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 bd7e8f708adf
children 3b04e921c93d
comparison
equal deleted inserted replaced
466:716d44ba42df 467:4d0aa75a82f1
37 37
38 self._owner = owner 38 self._owner = owner
39 39
40 self.width = 0.025 40 self.width = 0.025
41 self.height = 0.025 41 self.height = 0.025
42
43 self._damage = 1
42 44
43 def create(self, location): 45 def create(self, location):
44 self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet") 46 self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet")
45 fife.InstanceVisual.create(self._instance) 47 fife.InstanceVisual.create(self._instance)
46 48
70 self._totaltime += self._scene.timedelta 72 self._totaltime += self._scene.timedelta
71 if self._running and self._totaltime < self._ttl: 73 if self._running and self._totaltime < self._ttl:
72 super(Projectile, self).update() 74 super(Projectile, self).update()
73 else: 75 else:
74 self.destroy() 76 self.destroy()
77
78 def _getDamage(self):
79 return self._damage
80
81 def _setDamage(self, dam):
82 self._damage = dam
75 83
76 ttl = property(_getTTL) 84 ttl = property(_getTTL)
77 owner = property(_getOwner) 85 owner = property(_getOwner)
86 damage = property(_getDamage, _setDamage)
78 87
79 class Weapon(object): 88 class Weapon(object):
80 def __init__(self, scene, ship, firerate): 89 def __init__(self, scene, ship, firerate):
81 self._scene = scene 90 self._scene = scene
82 self._model = self._scene.model 91 self._model = self._scene.model