comparison demos/shooter/scripts/ships/shipbase.py @ 471:7a79dc2a0592

Adding the credits window (still needs to be written) Hopefully fixed some memory leaks. Moved the flashing code to the appropriate spot (in ShipBase).
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 15 Apr 2010 15:53:06 +0000
parents 4d0aa75a82f1
children 10aff123c62c
comparison
equal deleted inserted replaced
470:3b04e921c93d 471:7a79dc2a0592
34 34
35 self._ship = ship 35 self._ship = ship
36 self._ship.instance.addActionListener(self) 36 self._ship.instance.addActionListener(self)
37 37
38 def onInstanceActionFinished(self, instance, action): 38 def onInstanceActionFinished(self, instance, action):
39 pass 39 if action.getId() == 'flash':
40 if self._ship._flashing and self._ship._flashnumber > 0:
41 self._ship.instance.act('flash', self._ship.instance.getFacingLocation())
42 self._ship._flashnumber -= 1
43 else:
44 self._ship._flashing = False
45 self._ship._flashnumber = 0
40 46
41 class Ship(SpaceObject): 47 class Ship(SpaceObject):
42 def __init__(self, scene, name, findInstance=True): 48 def __init__(self, scene, name, findInstance=True):
43 super(Ship, self).__init__(scene, name, findInstance) 49 super(Ship, self).__init__(scene, name, findInstance)
44 50
62 self._instance.act('flash', self._instance.getFacingLocation()) 68 self._instance.act('flash', self._instance.getFacingLocation())
63 self._flashnumber = number 69 self._flashnumber = number
64 self._flashing = True 70 self._flashing = True
65 71
66 def fire(self, direction): 72 def fire(self, direction):
67 if self._weapon: 73 if self._weapon and self._hitpoints > 0:
68 return self._weapon.fire(direction) 74 return self._weapon.fire(direction)
69 75
70 return None 76 return None
71 77
72 def applyHit(self, hp): 78 def applyHit(self, hp):