comparison demos/shooter/scripts/scene.py @ 452:f07d779362da

Added different enemy types which behave differently.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 03 Apr 2010 19:19:33 +0000
parents f463ab431cc0
children cf53848fb187
comparison
equal deleted inserted replaced
451:f463ab431cc0 452:f07d779362da
22 # #################################################################### 22 # ####################################################################
23 23
24 from fife import fife 24 from fife import fife
25 from scripts.ships.shipbase import Ship 25 from scripts.ships.shipbase import Ship
26 from scripts.ships.player import Player 26 from scripts.ships.player import Player
27 from scripts.ships.enemies import *
27 from scripts.common.helpers import Rect 28 from scripts.common.helpers import Rect
28 29
29 30
30 class SceneNode(object): 31 class SceneNode(object):
31 def __init__(self, spaceobjects = None): 32 def __init__(self, spaceobjects = None):
71 72
72 for instance in enemies: 73 for instance in enemies:
73 objectName = instance.getObject().getId() 74 objectName = instance.getObject().getId()
74 print objectName 75 print objectName
75 76
76 enemy = Ship(self._model, 'enemy', self._layer, False) 77 if objectName == "saucer1":
78 enemy = Saucer1(self._model, 'enemy', self._layer, False)
79 elif objectName == "saucer2":
80 enemy = Saucer2(self._model, 'enemy', self._layer, False)
81 else:
82 enemy = Ship(self._model, 'enemy', self._layer, False)
83
77 enemy.instance = instance 84 enemy.instance = instance
78 enemy.width = 0.075
79 enemy.height = 0.075
80 enemy.velocity.x = -0.13
81 enemy.start() 85 enemy.start()
82 86
83 loc = instance.getLocation().getExactLayerCoordinates() 87 loc = instance.getLocation().getExactLayerCoordinates()
84 nodeindex = int(loc.x * xscale) 88 nodeindex = int(loc.x * xscale)
85 self._nodes[nodeindex].spaceobjects.append(enemy) 89 self._nodes[nodeindex].spaceobjects.append(enemy)