comparison demos/shooter/scripts/ships/enemies.py @ 477:6b33d80b468b

Projectiles are now part of the scene. Cleaned up the scene update() function. Moved garbage collection to the beginning of the frame. Introduced global object types. Projectiles now only check for collisions in a limited number of scene nodes rather than the entire screen.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 22 Apr 2010 19:52:34 +0000
parents afde89c1d50b
children ab28994820dd
comparison
equal deleted inserted replaced
476:78a1eb57c074 477:6b33d80b468b
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 # #################################################################### 22 # ####################################################################
23 23
24 from fife import fife 24 from fife import fife
25 from scripts.ships.shipbase import * 25 from scripts.ships.shipbase import *
26 from scripts.common.baseobject import *
26 from scripts.common.helpers import Rect 27 from scripts.common.helpers import Rect
27 from scripts.weapons import * 28 from scripts.weapons import *
28 29
29 30
30 class EnemyActionListener(ShipActionListener): 31 class EnemyActionListener(ShipActionListener):
48 49
49 class Saucer1(Ship): 50 class Saucer1(Ship):
50 def __init__(self, scene, name, instance, findInstance=True): 51 def __init__(self, scene, name, instance, findInstance=True):
51 super(Saucer1, self).__init__(scene, name, findInstance) 52 super(Saucer1, self).__init__(scene, name, findInstance)
52 self._instance = instance 53 self._instance = instance
54 self._type = SHTR_ENEMYSHIP
53 self._dir = 0 55 self._dir = 0
54 self._time = 500 56 self._time = 500
55 self.width = 0.2 57 self.width = 0.2
56 self.height = 0.075 58 self.height = 0.075
57 self.velocity.x = -0.5 59 self.velocity.x = -0.5
87 89
88 class Saucer2(Ship): 90 class Saucer2(Ship):
89 def __init__(self, scene, name, instance, findInstance=True): 91 def __init__(self, scene, name, instance, findInstance=True):
90 super(Saucer2, self).__init__(scene, name, findInstance) 92 super(Saucer2, self).__init__(scene, name, findInstance)
91 self._instance = instance 93 self._instance = instance
94 self._type = SHTR_ENEMYSHIP
92 self._dir = 0 95 self._dir = 0
93 self._time = 1000 96 self._time = 1000
94 self.width = 0.2 97 self.width = 0.2
95 self.height = 0.2 98 self.height = 0.2
96 self.velocity.x = -0.1 99 self.velocity.x = -0.1
129 132
130 class DiagSaucer(Ship): 133 class DiagSaucer(Ship):
131 def __init__(self, scene, name, direction, instance, findInstance=True): 134 def __init__(self, scene, name, direction, instance, findInstance=True):
132 super(DiagSaucer, self).__init__(scene, name, findInstance) 135 super(DiagSaucer, self).__init__(scene, name, findInstance)
133 self._instance = instance 136 self._instance = instance
137 self._type = SHTR_ENEMYSHIP
134 self.width = 0.2 138 self.width = 0.2
135 self.height = 0.075 139 self.height = 0.075
136 140
137 if direction == 0: 141 if direction == 0:
138 self._ythrust = 0.25 142 self._ythrust = 0.25
156 160
157 class Streaker(Ship): 161 class Streaker(Ship):
158 def __init__(self, scene, name, instance, findInstance=True): 162 def __init__(self, scene, name, instance, findInstance=True):
159 super(Streaker, self).__init__(scene, name, findInstance) 163 super(Streaker, self).__init__(scene, name, findInstance)
160 self._instance = instance 164 self._instance = instance
165 self._type = SHTR_ENEMYSHIP
161 self.width = 0.2 166 self.width = 0.2
162 self.height = 0.2 167 self.height = 0.2
163 168
164 self._maxvelocity = 2.0 169 self._maxvelocity = 2.0
165 170
190 195
191 class Boss(Ship): 196 class Boss(Ship):
192 def __init__(self, scene, name, instance, findInstance=True): 197 def __init__(self, scene, name, instance, findInstance=True):
193 super(Boss, self).__init__(scene, name, findInstance) 198 super(Boss, self).__init__(scene, name, findInstance)
194 self._instance = instance 199 self._instance = instance
200 self._type = SHTR_LASTBOSS
195 self.width = 0.85 201 self.width = 0.85
196 self.height = 0.25 202 self.height = 0.25
197 203
198 self._maxvelocity = 2.0 204 self._maxvelocity = 2.0
199 205