Mercurial > fife-parpg
annotate demos/shooter/scripts/ships/enemies.py @ 469:5994e61cdebd
Added a widget to be displayed after the player completes the game.
Renamed the showHighScoreDialog function to saveScore.
Player can no longer collide with the boss causing the boss to be destroyed. The player now gets destroyed and the boss takes no damage.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 14 Apr 2010 17:42:24 +0000 |
parents | 4d0aa75a82f1 |
children | 3b04e921c93d |
rev | line source |
---|---|
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # Copyright (C) 2005-2009 by the FIFE team |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # http://www.fifengine.de |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from fife import fife |
462
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
25 from scripts.ships.shipbase import * |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 from scripts.common.helpers import Rect |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
27 from scripts.weapons import * |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
462
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
30 class EnemyActionListener(ShipActionListener): |
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
31 def __init__(self, ship): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
32 super(EnemyActionListener, self).__init__(ship) |
462
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
33 |
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
34 def onInstanceActionFinished(self, instance, action): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
35 if action.getId() == 'explode': |
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
36 self._ship.removeFromScene() |
462
c4f745a566d6
Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
460
diff
changeset
|
37 |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
38 class BossActionListener(ShipActionListener): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
39 def __init__(self, ship): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
40 super(BossActionListener, self).__init__(ship) |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
41 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
42 def onInstanceActionFinished(self, instance, action): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
43 if action.getId() == 'explode': |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
44 self._ship.removeFromScene() |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
45 self._ship.endLevel() |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
46 |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 class Saucer1(Ship): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
48 def __init__(self, scene, name, instance, findInstance=True): |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
452
diff
changeset
|
49 super(Saucer1, self).__init__(scene, name, findInstance) |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
50 self._instance = instance |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self._time = 500 |
460
5e1d6e40d19d
Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
459
diff
changeset
|
53 self.width = 0.2 |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 self.height = 0.075 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self.velocity.x = -0.5 |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
452
diff
changeset
|
56 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
57 self.weapon = Cannon(self._scene, self, 1000) |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
58 self.weapon.projectilevelocity = 0.4 |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
59 |
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
60 self._actionlistener = EnemyActionListener(self) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
61 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
62 self.hitpoints = 1 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
63 self.scorevalue = 50 |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
65 def update(self): |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 if self._dir == 1: |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
67 self.applyThrust(fife.DoublePoint(0,-0.5)) |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 elif self._dir == 0: |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
69 self.applyThrust(fife.DoublePoint(0,0.5)) |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 if self._time >= 1000: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 self._dir = 1 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 self._time = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
79 self._time += self._scene.timedelta |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
81 super(Saucer1, self).update() |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 class Saucer2(Ship): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
84 def __init__(self, scene, name, instance, findInstance=True): |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
452
diff
changeset
|
85 super(Saucer2, self).__init__(scene, name, findInstance) |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
86 self._instance = instance |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 self._time = 1000 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 self.width = 0.2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 self.height = 0.2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 self.velocity.x = -0.1 |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
452
diff
changeset
|
92 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
93 self.weapon = Cannon(self._scene, self, 2000) |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
94 self.weapon.projectilevelocity = 0.4 |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
95 |
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
96 self._actionlistener = EnemyActionListener(self) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
97 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
98 self.hitpoints = 2 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
99 self.scorevalue = 100 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
100 |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
102 def update(self): |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 if self._dir == 1: |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
104 self.applyThrust(fife.DoublePoint(0,-0.25)) |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 elif self._dir == 0: |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
106 self.applyThrust(fife.DoublePoint(0,0.25)) |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 if self._time >= 2000: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 self._dir = 1 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 self._time = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
116 self._time += self._scene.timedelta |
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
118 super(Saucer2, self).update() |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
119 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
120 class DiagSaucer(Ship): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
121 def __init__(self, scene, name, direction, instance, findInstance=True): |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
122 super(DiagSaucer, self).__init__(scene, name, findInstance) |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
123 self._instance = instance |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
124 self.width = 0.2 |
460
5e1d6e40d19d
Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
459
diff
changeset
|
125 self.height = 0.075 |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
126 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
127 if direction == 0: |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
128 self._ythrust = 0.25 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
129 else: |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
130 self._ythrust = -0.25 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
131 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
132 self.weapon = Cannon(self._scene, self, 2000) |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
133 self.weapon.projectilevelocity = 0.4 |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
134 |
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
135 self._actionlistener = EnemyActionListener(self) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
136 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
137 self.hitpoints = 1 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
138 self.scorevalue = 50 |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
139 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
140 def update(self): |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
141 self.applyThrust(fife.DoublePoint(-0.25,self._ythrust)) |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
142 super(DiagSaucer, self).update() |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
143 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
144 class Streaker(Ship): |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
145 def __init__(self, scene, name, instance, findInstance=True): |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
146 super(Streaker, self).__init__(scene, name, findInstance) |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
147 self._instance = instance |
460
5e1d6e40d19d
Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
459
diff
changeset
|
148 self.width = 0.2 |
5e1d6e40d19d
Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
459
diff
changeset
|
149 self.height = 0.2 |
5e1d6e40d19d
Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
459
diff
changeset
|
150 |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
151 self._maxvelocity = 2.0 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
152 |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
153 self.weapon = Cannon(self._scene, self, 2000) |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
154 self.weapon.projectilevelocity = 1.0 |
463
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
155 |
ac0f62a07a3e
Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
462
diff
changeset
|
156 self._actionlistener = EnemyActionListener(self) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
157 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
158 self.hitpoints = 2 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
159 self.scorevalue = 150 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
160 |
459
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
161 def update(self): |
302a69c5141d
Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
162 self.applyThrust(fife.DoublePoint(-0.40,0)) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
163 super(Streaker, self).update() |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
164 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
165 class Boss(Ship): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
166 def __init__(self, scene, name, instance, findInstance=True): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
167 super(Boss, self).__init__(scene, name, findInstance) |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
168 self._instance = instance |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
169 self.width = 0.2 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
170 self.height = 0.2 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
171 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
172 self._maxvelocity = 2.0 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
173 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
174 self.weapon = Cannon(self._scene, self, 1000) |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
175 self.weapon.projectilevelocity = 0.5 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
176 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
177 self._actionlistener = BossActionListener(self) |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
178 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
179 self.hitpoints = 20 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
180 self.scorevalue = 1000 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
181 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
182 def endLevel(self): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
183 self._scene.endLevel() |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
184 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
185 def update(self): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
463
diff
changeset
|
186 super(Boss, self).update() |