Mercurial > fife-parpg
annotate demos/shooter/scripts/weapons.py @ 642:6e2151325017
* Added the ability to query the current running screen mode
* Added a method to detect the closest supported screen mode (not complete yet). If no matching screen modes are detected an exception is thrown.
* Small change to the way the screen is initialized. The screen mode now MUST be in the supported screen mode list before the screen will initialize.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 08 Oct 2010 21:22:02 +0000 |
parents | 5e6ff32a46fb |
children | 291ba2946c73 |
rev | line source |
---|---|
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
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:
490
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:
490
diff
changeset
|
5 # http://www.fifengine.net |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from fife import fife |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
25 from scripts.common.baseobject import * |
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
|
26 from fife.extensions.fife_math import normalize, rotatePoint |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
28 class Projectile(SpaceObject): |
490
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
29 """ |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
30 Represents a projectile (or bullet or fireball) in the scene. |
490
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
31 |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
32 This is the entity that weapons fire. Projectiles have an owner |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
33 and a time to live. They are also what cause damage to ships |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
34 and other entities. |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
35 """ |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
36 def __init__(self, scene, owner, projectileName, timeToLive): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
37 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
38 @param scene: The scene |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
39 @type scene: L{Scene} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
40 @param owner: The ship that fired the projectile |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
41 @type owner: L{Ship} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
42 @param projectileName: The name of the FIFE object to load |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
43 @type projectilName: C{string} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
44 @param timeToLive: The length of time in milliseconds the projectile will |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
45 remain active before destroying itself. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
46 @type timeToLive: C{int} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
47 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
48 """ |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
49 super(Projectile, self).__init__(scene, projectileName, False) |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
50 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._obj = self._model.getObject(self._name, "http://www.fifengine.de/xml/tutorial") |
449
1cf56403347a
Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
448
diff
changeset
|
52 |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
53 self._type = SHTR_PROJECTILE |
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
54 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self._ttl = timeToLive |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 self._starttime = 0 |
449
1cf56403347a
Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
448
diff
changeset
|
57 self._totaltime = 0 |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
58 |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
59 self._owner = owner |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
60 |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
61 self.width = 0.025 |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
62 self.height = 0.025 |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
63 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
64 self._damage = 1 |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
65 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 def create(self, location): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
67 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
68 Spawns the projectile. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
69 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
70 @param location: The location to create the projectile |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
71 @type location: L{fife.Location} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
72 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
73 @note: This is called by L{Projectile.run} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
74 """ |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet") |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 fife.InstanceVisual.create(self._instance) |
473
b78020d31186
Small update to ensure python doesn't try to delete objects that FIFE owns.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
472
diff
changeset
|
77 self._instance.thisown = 0 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
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 def run(self, velocity, location): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
80 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
81 Start the projectile on it's path. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
82 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
83 @param velocity: The starting velocity of the projectile |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
84 @type velocity: L{fife.DoublePoint} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
85 @param location: The location to create the projectile |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
86 @type location: L{fife.Location} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
87 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
88 """ |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 if not self._running: |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 self._velocity = velocity |
447
64676ea55472
Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
446
diff
changeset
|
91 self._velocity.x /= self._xscale |
64676ea55472
Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
446
diff
changeset
|
92 self._velocity.y /= self._yscale |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 self.create(location) |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 self._running = True |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
97 self._starttime = self._scene.time |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 def _getTTL(self): |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 return self._ttl |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
101 |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
102 def _getOwner(self): |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
103 return self._owner |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
105 def update(self): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
106 self._totaltime += self._scene.timedelta |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
107 if self._running and self._totaltime < self._ttl: |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
108 super(Projectile, self).update() |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 else: |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 self.destroy() |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
111 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
112 def _getDamage(self): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
113 return self._damage |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
114 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
115 def _setDamage(self, dam): |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
116 self._damage = dam |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 ttl = property(_getTTL) |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
119 owner = property(_getOwner) |
467
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
120 damage = property(_getDamage, _setDamage) |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 class Weapon(object): |
490
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
123 """ |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
124 Weapon |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
125 |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
126 This class is a super class and is meant to be inherited and |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
127 not used directly. You should implement fire() in the sub- |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
128 class. The Weapon class spawns Projectile(s) and fires them |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
129 in the specified direction at a specified fire rate. |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
130 """ |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
131 def __init__(self, scene, ship, firerate): |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
132 self._scene = scene |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
133 self._model = self._scene.model |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
134 self._layer = self._scene.objectlayer |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 self._ship = ship |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 self._firerate = firerate |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 self._lastfired = 0 |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
138 self._projectileVelocity = 0.75 |
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
|
139 self._soundclip = None |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
141 def fire(self, direction): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
142 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
143 Fires the weapon in the specified direction. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
144 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
145 @param direction: A normalized vector specifying the direction to fire the projectile |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
146 @type direction: L{fife.DoublePoint} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
147 """ |
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
|
148 pass |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
149 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
150 def _getProjectileVelocity(self): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
151 return self._projectileVelocity |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
152 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
153 def _setProjectileVelocity(self, vel): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
154 self._projectileVelocity = vel |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
155 |
475
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
156 def _getLastFired(self): |
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
157 return self._lastfired |
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
158 |
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
159 def _setLastFired(self, time): |
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
160 self._lastfired = time |
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
161 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
162 projectilevelocity = property(_getProjectileVelocity, _setProjectileVelocity) |
475
afde89c1d50b
Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
473
diff
changeset
|
163 lastfired = property(_getLastFired, _setLastFired) |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
164 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
165 class Cannon(Weapon): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
166 def __init__(self, scene, ship, firerate): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
167 super(Cannon, self).__init__(scene, ship, firerate) |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
168 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
169 self._projectileVelocity = 0.75 |
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
|
170 self._soundclip = scene.soundmanager.createSoundEmitter("sounds/cannon.ogg") |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
171 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
172 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
173 def fire(self, direction): |
453
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
174 velocity = normalize(direction) |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
175 velocity.x = velocity.x * self._projectileVelocity |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
176 velocity.y = velocity.y * self._projectileVelocity |
cf53848fb187
Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
451
diff
changeset
|
177 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
178 if (self._scene.time - self._lastfired) > self._firerate: |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
179 pjctl = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
180 pjctl.run(velocity, self._ship.location) |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
181 self._lastfired = self._scene.time |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
182 self._scene.addObjectToScene(pjctl) |
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
|
183 if self._soundclip: |
500
5e6ff32a46fb
Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
494
diff
changeset
|
184 location = self._ship.location.getExactLayerCoordinates() |
5e6ff32a46fb
Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
494
diff
changeset
|
185 self._soundclip.position = (location.x, location.y) |
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
|
186 self._soundclip.play() |
470
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
187 |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
188 class FireBall(Weapon): |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
189 def __init__(self, scene, ship, firerate): |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
190 super(FireBall, self).__init__(scene, ship, firerate) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
191 |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
192 self._projectileVelocity = 0.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
|
193 self._soundclip = scene.soundmanager.createSoundEmitter("sounds/fireball.ogg") |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
194 |
470
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
195 def fire(self, direction): |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
196 velocity = normalize(direction) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
197 velocity.x = velocity.x * self._projectileVelocity |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
198 velocity.y = velocity.y * self._projectileVelocity |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
199 |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
200 if (self._scene.time - self._lastfired) > self._firerate: |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
201 pjctl = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
202 pjctl.run(velocity, self._ship.location) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
203 self._lastfired = self._scene.time |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
204 self._scene.addObjectToScene(pjctl) |
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
|
205 if self._soundclip: |
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
|
206 self._soundclip.play() |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
207 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
208 class FireBallBurst(Weapon): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
209 def __init__(self, scene, ship, firerate, burstrate, burstnumber): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
210 super(FireBallBurst, self).__init__(scene, ship, firerate) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
211 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
212 self._projectileVelocity = 0.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
|
213 self._soundclip = scene.soundmanager.createSoundEmitter("sounds/fireball.ogg") |
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
|
214 |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
215 self._burstrate = burstrate |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
216 self._burstnumber = int(burstnumber) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
217 self._burstcount = int(burstnumber) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
218 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
219 self._lastburstfired = 0 |
470
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
220 |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
221 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
222 def fire(self, direction): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
223 velocity = normalize(direction) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
224 velocity.x = velocity.x * self._projectileVelocity |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
225 velocity.y = velocity.y * self._projectileVelocity |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
226 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
227 if (self._scene.time - self._lastfired) > self._firerate: |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
228 if (self._scene.time - self._lastburstfired) > self._burstrate and self._burstcount > 0: |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
229 pjctl = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
230 pjctl.run(velocity, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
231 self._scene.addObjectToScene(pjctl) |
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
|
232 |
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
|
233 if self._soundclip: |
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
|
234 self._soundclip.play() |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
235 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
236 self._lastburstfired = self._scene.time |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
237 self._burstcount -= 1 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
238 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
239 if self._burstcount <= 0: |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
240 self._lastfired = self._scene.time |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
241 self._burstcount = int(self._burstnumber) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
242 self._lastburstfired = 0 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
243 |
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
|
244 |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
245 class FireBallSpread(Weapon): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
246 def __init__(self, scene, ship, firerate): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
247 super(FireBallSpread, self).__init__(scene, ship, firerate) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
248 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
249 self._projectileVelocity = 0.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
|
250 self._soundclip = scene.soundmanager.createSoundEmitter("sounds/fireball.ogg") |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
251 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
252 def fire(self, direction): |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
253 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
254 if (self._scene.time - self._lastfired) > self._firerate: |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
255 velocity = normalize(direction) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
256 velocity.x = velocity.x * self._projectileVelocity |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
257 velocity.y = velocity.y * self._projectileVelocity |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
258 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
259 origin = fife.DoublePoint(0,0) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
260 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
261 p1 = rotatePoint(origin, velocity, -30) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
262 p2 = rotatePoint(origin, velocity, -20) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
263 p3 = rotatePoint(origin, velocity, -10) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
264 p4 = rotatePoint(origin, velocity, 0) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
265 p5 = rotatePoint(origin, velocity, 10) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
266 p6 = rotatePoint(origin, velocity, 20) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
267 p7 = rotatePoint(origin, velocity, 30) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
268 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
269 pjctl1 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
270 pjctl1.run(p1, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
271 self._scene.addObjectToScene(pjctl1) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
272 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
273 pjctl2 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
274 pjctl2.run(p2, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
275 self._scene.addObjectToScene(pjctl2) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
276 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
277 pjctl3 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
278 pjctl3.run(p3, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
279 self._scene.addObjectToScene(pjctl3) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
280 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
281 pjctl4 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
282 pjctl4.run(p4, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
283 self._scene.addObjectToScene(pjctl4) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
284 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
285 pjctl5 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
286 pjctl5.run(p5, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
287 self._scene.addObjectToScene(pjctl5) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
288 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
289 pjctl6 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
290 pjctl6.run(p6, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
291 self._scene.addObjectToScene(pjctl6) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
292 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
293 pjctl7 = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
294 pjctl7.run(p7, self._ship.location) |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
295 self._scene.addObjectToScene(pjctl7) |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
296 |
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
|
297 if self._soundclip: |
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
|
298 self._soundclip.play() |
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
|
299 |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
300 self._lastfired = self._scene.time |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
301 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
302 class CannonSpread5(Weapon): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
303 def __init__(self, scene, ship, firerate): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
304 super(CannonSpread5, self).__init__(scene, ship, firerate) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
305 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
306 self._projectileVelocity = 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
|
307 self._soundclip = scene.soundmanager.createSoundEmitter("sounds/cannon.ogg") |
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
|
308 |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
309 def fire(self, direction): |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
310 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
311 if (self._scene.time - self._lastfired) > self._firerate: |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
312 velocity = normalize(direction) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
313 velocity.x = velocity.x * self._projectileVelocity |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
314 velocity.y = velocity.y * self._projectileVelocity |
472
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
315 |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
316 origin = fife.DoublePoint(0,0) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
317 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
318 p2 = rotatePoint(origin, velocity, -10) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
319 p3 = rotatePoint(origin, velocity, -5) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
320 p4 = rotatePoint(origin, velocity, 0) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
321 p5 = rotatePoint(origin, velocity, 5) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
322 p6 = rotatePoint(origin, velocity, 10) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
323 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
324 pjctl2 = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
325 pjctl2.run(p2, self._ship.location) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
326 self._scene.addObjectToScene(pjctl2) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
327 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
328 pjctl3 = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
329 pjctl3.run(p3, self._ship.location) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
330 self._scene.addObjectToScene(pjctl3) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
331 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
332 pjctl4 = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
333 pjctl4.run(p4, self._ship.location) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
334 self._scene.addObjectToScene(pjctl4) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
335 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
336 pjctl5 = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
337 pjctl5.run(p5, self._ship.location) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
338 self._scene.addObjectToScene(pjctl5) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
339 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
340 pjctl6 = Projectile(self._scene, self._ship, "bullet1", 3000 ) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
341 pjctl6.run(p6, self._ship.location) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
342 self._scene.addObjectToScene(pjctl6) |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
343 |
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
|
344 if self._soundclip: |
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
|
345 self._soundclip.play() |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
346 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
347 self._lastfired = self._scene.time |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
348 |