Mercurial > fife-parpg
annotate demos/shooter/scripts/weapons.py @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | 291ba2946c73 |
children |
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 * |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
27 class Projectile(SpaceObject): |
490
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
28 """ |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
29 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
|
30 |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
31 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
|
32 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
|
33 and other entities. |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
34 """ |
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
|
35 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
|
36 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
37 @param scene: The scene |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
38 @type scene: L{Scene} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
39 @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
|
40 @type owner: L{Ship} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
41 @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
|
42 @type projectilName: C{string} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
43 @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
|
44 remain active before destroying itself. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
45 @type timeToLive: C{int} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
46 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
47 """ |
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
|
48 super(Projectile, self).__init__(scene, projectileName, False) |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
49 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 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
|
51 |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
52 self._type = SHTR_PROJECTILE |
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
53 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 self._ttl = timeToLive |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self._starttime = 0 |
449
1cf56403347a
Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
448
diff
changeset
|
56 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
|
57 |
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 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
|
59 |
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 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
|
61 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
|
62 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
63 self._damage = 1 |
448
5e2ec84902a7
Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
447
diff
changeset
|
64 |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 def create(self, location): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
66 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
67 Spawns the projectile. |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
68 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
69 @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
|
70 @type location: L{fife.Location} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
71 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
72 @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
|
73 """ |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
78 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
|
79 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
80 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
|
81 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
82 @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
|
83 @type velocity: L{fife.DoublePoint} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
84 @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
|
85 @type location: L{fife.Location} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
86 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
87 """ |
446
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 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
|
92 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 self.create(location) |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 self._running = True |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
96 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
|
97 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 def _getTTL(self): |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 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
|
100 |
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 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
|
102 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
|
103 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
104 def update(self): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
105 self._totaltime += self._scene.timedelta |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
106 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
|
107 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
|
108 else: |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 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
|
110 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
111 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
|
112 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
|
113 |
4d0aa75a82f1
Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
454
diff
changeset
|
114 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
|
115 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
|
116 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 class Weapon(object): |
490
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
122 """ |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
123 Weapon |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
124 |
939a4dc12ca1
Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
483
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 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
|
129 """ |
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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 self._ship = ship |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 self._firerate = firerate |
2046a1f2f5f2
Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
140 def fire(self, direction): |
494
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
141 """ |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
142 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
|
143 |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
144 @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
|
145 @type direction: L{fife.DoublePoint} |
e241d7553496
Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
492
diff
changeset
|
146 """ |
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
|
147 pass |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
148 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
149 def _getProjectileVelocity(self): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
150 return self._projectileVelocity |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
151 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
152 def _setProjectileVelocity(self, vel): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
153 self._projectileVelocity = vel |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
154 |
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
|
155 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
|
156 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
|
157 |
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 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
|
159 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
|
160 |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
161 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
|
162 lastfired = property(_getLastFired, _setLastFired) |
454
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
163 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
164 class Cannon(Weapon): |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
165 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
|
166 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
|
167 |
bd7e8f708adf
Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
453
diff
changeset
|
168 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
|
169 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
|
170 |
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 def fire(self, direction): |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
173 velocity = fife.DoublePoint(direction) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
174 velocity.normalize() |
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
|
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): |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
196 velocity = fife.DoublePoint(direction) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
197 velocity.normalize() |
470
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
198 velocity.x = velocity.x * self._projectileVelocity |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
199 velocity.y = velocity.y * self._projectileVelocity |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
200 |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
201 if (self._scene.time - self._lastfired) > self._firerate: |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
202 pjctl = Projectile(self._scene, self._ship, "fireball", 6000 ) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
203 pjctl.run(velocity, self._ship.location) |
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
204 self._lastfired = self._scene.time |
477
6b33d80b468b
Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
475
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 |
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 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
|
210 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
|
211 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
|
212 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
213 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
|
214 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
|
215 |
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
|
216 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
|
217 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
|
218 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
|
219 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
220 self._lastburstfired = 0 |
470
3b04e921c93d
Added the fireball projectile.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
467
diff
changeset
|
221 |
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
|
222 |
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 def fire(self, direction): |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
224 velocity = fife.DoublePoint(direction) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
225 velocity.normalize() |
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
|
226 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
|
227 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
|
228 |
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 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 |
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
|
235 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
|
236 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
|
237 |
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 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
|
239 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
|
240 |
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 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
|
242 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
|
243 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
|
244 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
|
245 |
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
|
246 |
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
|
247 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
|
248 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
|
249 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
|
250 |
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 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
|
252 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
|
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 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
|
255 |
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 if (self._scene.time - self._lastfired) > self._firerate: |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
257 velocity = fife.DoublePoint(direction) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
258 velocity.normalize() |
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
|
259 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
|
260 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
|
261 |
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 origin = fife.DoublePoint(0,0) |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
263 |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
264 p1 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
265 p2 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
266 p3 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
267 p4 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
268 p5 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
269 p6 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
270 p7 = fife.DoublePoint(velocity) |
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
|
271 |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
272 p1.rotate(origin, -30) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
273 p2.rotate(origin, -20) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
274 p3.rotate(origin, -10) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
275 p4.rotate(origin, 0) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
276 p5.rotate(origin, 10) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
277 p6.rotate(origin, 20) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
278 p7.rotate(origin, 30) |
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
|
279 |
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 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
|
281 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
|
282 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
|
283 |
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 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
|
285 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
|
286 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
|
287 |
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 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
|
289 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
|
290 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
|
291 |
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 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
|
293 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
|
294 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
|
295 |
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 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
|
297 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
|
298 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
|
299 |
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 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
|
301 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
|
302 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
|
303 |
3164715a0621
Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
471
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 |
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 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
|
309 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
|
310 |
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
|
311 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
|
312 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
317 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
|
318 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
|
319 |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
320 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
|
321 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
322 if (self._scene.time - self._lastfired) > self._firerate: |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
323 velocity = fife.DoublePoint(direction) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
324 velocity.normalize() |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
325 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
|
326 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
|
327 |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
328 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
|
329 |
645
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
330 p2 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
331 p3 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
332 p4 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
333 p5 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
334 p6 = fife.DoublePoint(velocity) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
335 |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
336 p2.rotate(origin, -10) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
337 p3.rotate(origin, -5) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
338 p4.rotate(origin, 0) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
339 p5.rotate(origin, 5) |
291ba2946c73
* Added the ability to normalize a 2D and 3D point.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
500
diff
changeset
|
340 p6.rotate(origin, 10) |
479
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
341 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
358 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
|
359 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
|
360 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
|
361 |
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
|
362 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
|
363 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
|
364 |
ab28994820dd
Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
477
diff
changeset
|
365 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
|
366 |