# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1271104884 0 # Node ID ac0f62a07a3e76b5f48a5b8c6996faeec306d438 # Parent c4f745a566d6628a0c1037cad3fa3bef5504e7db Added enemy explosions and other animations. Remove the enemies from the scene after the explosion animation is complete. diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer1/explode/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_0.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_0.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_1.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_2.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_2.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_3.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_3.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_4.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_4.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/explode/saucer1_5.png Binary file demos/shooter/objects/ships/saucer1/explode/saucer1_5.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/flash/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer1/flash/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,5 @@ + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/flash/saucer1_0.png Binary file demos/shooter/objects/ships/saucer1/flash/saucer1_0.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/flash/saucer1_1.png Binary file demos/shooter/objects/ships/saucer1/flash/saucer1_1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/fly/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer1/fly/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,3 @@ + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/fly/saucer1.png Binary file demos/shooter/objects/ships/saucer1/fly/saucer1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/object.xml --- a/demos/shooter/objects/ships/saucer1/object.xml Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/objects/ships/saucer1/object.xml Mon Apr 12 20:41:24 2010 +0000 @@ -1,4 +1,12 @@ - - + + + + + + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer1/saucer1.png Binary file demos/shooter/objects/ships/saucer1/saucer1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer2/explode/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_0.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_0.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_1.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_2.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_2.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_3.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_3.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_4.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_4.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/explode/saucer2_5.png Binary file demos/shooter/objects/ships/saucer2/explode/saucer2_5.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/flash/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer2/flash/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,5 @@ + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/flash/saucer2_0.png Binary file demos/shooter/objects/ships/saucer2/flash/saucer2_0.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/flash/saucer2_1.png Binary file demos/shooter/objects/ships/saucer2/flash/saucer2_1.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/fly/animation.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/objects/ships/saucer2/fly/animation.xml Mon Apr 12 20:41:24 2010 +0000 @@ -0,0 +1,3 @@ + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/fly/saucer2.png Binary file demos/shooter/objects/ships/saucer2/fly/saucer2.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/object.xml --- a/demos/shooter/objects/ships/saucer2/object.xml Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/objects/ships/saucer2/object.xml Mon Apr 12 20:41:24 2010 +0000 @@ -1,4 +1,12 @@ - - + + + + + + + + + + diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/objects/ships/saucer2/saucer2.png Binary file demos/shooter/objects/ships/saucer2/saucer2.png has changed diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/scripts/common/baseobject.py --- a/demos/shooter/scripts/common/baseobject.py Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/scripts/common/baseobject.py Mon Apr 12 20:41:24 2010 +0000 @@ -74,7 +74,6 @@ def destroy(self): self._running = False - self._layer.deleteInstance(self._instance) def applyThrust(self, vector): self._velocity.x += (vector.x * (self._scene.timedelta/1000.0))/self._xscale @@ -110,6 +109,10 @@ self._velocity.x += (norm.x * (self._scene.timedelta/1000.0))/self._xscale self._velocity.y += (norm.y * (self._scene.timedelta/1000.0))/self._yscale + + def removeFromScene(self): + self._scene.removeObjectFromScene(self) + self._layer.deleteInstance(self._instance) def _isRunning(self): return self._running diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/scripts/scene.py --- a/demos/shooter/scripts/scene.py Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/scripts/scene.py Mon Apr 12 20:41:24 2010 +0000 @@ -99,19 +99,18 @@ print objectName if objectName == "dodge1": - enemy = Saucer1(self, 'enemy', False) + enemy = Saucer1(self, 'enemy', instance, False) elif objectName == "dodge2": - enemy = Saucer2(self, 'enemy', False) + enemy = Saucer2(self, 'enemy', instance, False) elif objectName == "diag_top_right": - enemy = DiagSaucer(self, 'enemy', 0, False) + enemy = DiagSaucer(self, 'enemy', 0, instance, False) elif objectName == "diag_bottom_right": - enemy = DiagSaucer(self, 'enemy', 1, False) + enemy = DiagSaucer(self, 'enemy', 1, instance, False) elif objectName == "streaker": - enemy = Streaker(self, 'enemy', False) + enemy = Streaker(self, 'enemy', instance, False) else: - enemy = Ship(self, 'enemy', False) + enemy = Ship(self, 'enemy', instance, False) - enemy.instance = instance enemy.start() loc = instance.getLocation().getExactLayerCoordinates() @@ -231,16 +230,17 @@ if obj != self._player: #TODO: enemy should fire weapon in their update function - obj.fire(fife.DoublePoint(-1,0)) + if obj.running: + obj.fire(fife.DoublePoint(-1,0)) - if obj.boundingbox.intersects(self._player.boundingbox): + if obj.running and obj.boundingbox.intersects(self._player.boundingbox): #player touched an enemy. Destroy player and #re-initialize scene if not self._player.invulnerable: self.playerHit() obj.destroy() - self._world.renderBoundingBox(obj) +# self._world.renderBoundingBox(obj) @@ -252,7 +252,7 @@ for o in screenlist: #cant get hit by your own bullet if p.owner != o: - if p.boundingbox.intersects(o.boundingbox): + if o.running and p.boundingbox.intersects(o.boundingbox): if o != self._player and p.owner.isplayer: self._player.applyScore(100) p.destroy() @@ -266,7 +266,7 @@ p.destroy() self.playerHit() - self._world.renderBoundingBox(p) +# self._world.renderBoundingBox(p) #build a list of projectiles to remove (ttl expired) diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/scripts/ships/enemies.py --- a/demos/shooter/scripts/ships/enemies.py Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/scripts/ships/enemies.py Mon Apr 12 20:41:24 2010 +0000 @@ -29,14 +29,16 @@ class EnemyActionListener(ShipActionListener): def __init__(self, ship): - super(PlayerActionListener, self).__init__(ship) + super(EnemyActionListener, self).__init__(ship) def onInstanceActionFinished(self, instance, action): - pass + if action.getId() == 'explode': + self._ship.removeFromScene() class Saucer1(Ship): - def __init__(self, scene, name, findInstance=True): + def __init__(self, scene, name, instance, findInstance=True): super(Saucer1, self).__init__(scene, name, findInstance) + self._instance = instance self._dir = 0 self._time = 500 self.width = 0.2 @@ -45,6 +47,8 @@ self.weapon = Cannon(self._scene, self, 1000) self.weapon.projectilevelocity = 0.4 + + self._actionlistener = EnemyActionListener(self) def update(self): if self._dir == 1: @@ -65,8 +69,9 @@ super(Saucer1, self).update() class Saucer2(Ship): - def __init__(self, scene, name, findInstance=True): + def __init__(self, scene, name, instance, findInstance=True): super(Saucer2, self).__init__(scene, name, findInstance) + self._instance = instance self._dir = 0 self._time = 1000 self.width = 0.2 @@ -75,6 +80,8 @@ self.weapon = Cannon(self._scene, self, 2000) self.weapon.projectilevelocity = 0.4 + + self._actionlistener = EnemyActionListener(self) def update(self): if self._dir == 1: @@ -95,8 +102,9 @@ super(Saucer2, self).update() class DiagSaucer(Ship): - def __init__(self, scene, name, direction, findInstance=True): + def __init__(self, scene, name, direction, instance, findInstance=True): super(DiagSaucer, self).__init__(scene, name, findInstance) + self._instance = instance self.width = 0.2 self.height = 0.075 @@ -107,15 +115,17 @@ self.weapon = Cannon(self._scene, self, 2000) self.weapon.projectilevelocity = 0.4 + + self._actionlistener = EnemyActionListener(self) def update(self): self.applyThrust(fife.DoublePoint(-0.25,self._ythrust)) super(DiagSaucer, self).update() class Streaker(Ship): - def __init__(self, scene, name, findInstance=True): + def __init__(self, scene, name, instance, findInstance=True): super(Streaker, self).__init__(scene, name, findInstance) - + self._instance = instance self.width = 0.2 self.height = 0.2 @@ -123,6 +133,8 @@ self.weapon = Cannon(self._scene, self, 2000) self.weapon.projectilevelocity = 1.0 + + self._actionlistener = EnemyActionListener(self) def update(self): self.applyThrust(fife.DoublePoint(-0.40,0)) diff -r c4f745a566d6 -r ac0f62a07a3e demos/shooter/scripts/ships/shipbase.py --- a/demos/shooter/scripts/ships/shipbase.py Mon Apr 12 19:01:41 2010 +0000 +++ b/demos/shooter/scripts/ships/shipbase.py Mon Apr 12 20:41:24 2010 +0000 @@ -67,8 +67,9 @@ return None def destroy(self): - self._scene.removeObjectFromScene(self) - super(Ship, self).destroy() + if self._running: + self._instance.act('explode', self._instance.getFacingLocation()) + super(Ship, self).destroy() def _isPlayer(self): return self._isplayer