Mercurial > fife-parpg
annotate demos/shooter/scripts/powerups.py @ 692:be625cdff350
This commit is to back port a fix in 0.3.3 dev branch to the current trunk. Adding boost_system as a required dependency as boost_filesystem is dependent on it. On linux distros with newer versions of gcc FIFE is failing to configure properly without boost_system in the lib list. [t:540]
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 08 Jun 2011 03:08:58 +0000 |
parents | 16ceb3228324 |
children |
rev | line source |
---|---|
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
491
c4168eb47a44
Adding some comments to the shooter demo. Updated the copyright date and FIFE URL as well.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
489
diff
changeset
|
4 # Copyright (C) 2005-2010 by the FIFE team |
c4168eb47a44
Adding some comments to the shooter demo. Updated the copyright date and FIFE URL as well.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
489
diff
changeset
|
5 # http://www.fifengine.net |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from fife import fife |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 from scripts.ships.shipbase import SpaceObject |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 from scripts.weapons import * |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 class PowerUp(SpaceObject): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 def __init__(self, scene, powerupName, instance, findInstance=True): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 super(PowerUp, self).__init__(scene, powerupName, findInstance) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 self.instance = instance |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 self._type = SHTR_POWERUP |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 self.width = 0.025 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 self.height = 0.025 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 def applyPowerUp(self, ship): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 self.destroy() |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 self._scene.queueObjectForRemoval(self) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 class CannonSpread5PU(PowerUp): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 def __init__(self, scene, powerupName, instance, findInstance=True): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 super(CannonSpread5PU, self).__init__(scene, powerupName, instance, findInstance) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self._dir = 0 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self._time = 1500 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 self._velocity.x = -0.25 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 self._velocity.y = 0 |
483
82d44c471959
Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
479
diff
changeset
|
50 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
491
diff
changeset
|
51 self._pickupclip = self._scene.soundmanager.createSoundEmitter("sounds/pickup.ogg") |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 def applyPowerUp(self, ship): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 ship.weapon = CannonSpread5(self._scene, ship, 300) |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
491
diff
changeset
|
55 self._pickupclip.play() |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 self.destroy() |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 self._scene.queueObjectForRemoval(self) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 def update(self): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 if self._dir == 1: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 self._velocity.y = -0.25 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 elif self._dir == 0: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 self._velocity.y = 0.25 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 if self._time >= 3000: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 if self._dir == 1: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 self._dir = 0 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 elif self._dir == 0: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 self._dir = 1 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 self._time = 0 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 self._time += self._scene.timedelta |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 super(CannonSpread5PU, self).update() |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 class ExtraLifePU(PowerUp): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 def __init__(self, scene, powerupName, instance, findInstance=True): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 super(ExtraLifePU, self).__init__(scene, powerupName, instance, findInstance) |
489
0324a3533988
Updated the Shooter demo credits.txt file and added the LICENSE file for all media included in the demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
80 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
491
diff
changeset
|
81 self._pickupclip = self._scene.soundmanager.createSoundEmitter("sounds/pickup.ogg") |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 def applyPowerUp(self, ship): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 ship.lives += 1 |
492
16ceb3228324
Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
491
diff
changeset
|
85 self._pickupclip.play() |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 self.destroy() |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 self._scene.queueObjectForRemoval(self) |
491
c4168eb47a44
Adding some comments to the shooter demo. Updated the copyright date and FIFE URL as well.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
489
diff
changeset
|
88 |