comparison demos/shooter/scripts/weapons.py @ 494:e241d7553496

Fixing the epydoc markup. Did some more commenting.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 10 May 2010 15:54:21 +0000
parents 16ceb3228324
children 5e6ff32a46fb
comparison
equal deleted inserted replaced
493:e29853880e87 494:e241d7553496
25 from scripts.common.baseobject import * 25 from scripts.common.baseobject import *
26 from fife.extensions.fife_math import normalize, rotatePoint 26 from fife.extensions.fife_math import normalize, rotatePoint
27 27
28 class Projectile(SpaceObject): 28 class Projectile(SpaceObject):
29 """ 29 """
30 Projectile 30 Represents a projectile (or bullet or fireball) in the scene.
31 31
32 This is the entity that weapons fire. Projectiles have an owner 32 This is the entity that weapons fire. Projectiles have an owner
33 and a time to live. They are also what cause damage to ships 33 and a time to live. They are also what cause damage to ships
34 and other entities. 34 and other entities.
35 """ 35 """
36 def __init__(self, scene, owner, projectileName, timeToLive): 36 def __init__(self, scene, owner, projectileName, timeToLive):
37 """
38 @param scene: The scene
39 @type scene: L{Scene}
40 @param owner: The ship that fired the projectile
41 @type owner: L{Ship}
42 @param projectileName: The name of the FIFE object to load
43 @type projectilName: C{string}
44 @param timeToLive: The length of time in milliseconds the projectile will
45 remain active before destroying itself.
46 @type timeToLive: C{int}
47
48 """
37 super(Projectile, self).__init__(scene, projectileName, False) 49 super(Projectile, self).__init__(scene, projectileName, False)
38 50
39 self._obj = self._model.getObject(self._name, "http://www.fifengine.de/xml/tutorial") 51 self._obj = self._model.getObject(self._name, "http://www.fifengine.de/xml/tutorial")
40 52
41 self._type = SHTR_PROJECTILE 53 self._type = SHTR_PROJECTILE
50 self.height = 0.025 62 self.height = 0.025
51 63
52 self._damage = 1 64 self._damage = 1
53 65
54 def create(self, location): 66 def create(self, location):
67 """
68 Spawns the projectile.
69
70 @param location: The location to create the projectile
71 @type location: L{fife.Location}
72
73 @note: This is called by L{Projectile.run}
74 """
55 self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet") 75 self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet")
56 fife.InstanceVisual.create(self._instance) 76 fife.InstanceVisual.create(self._instance)
57 self._instance.thisown = 0 77 self._instance.thisown = 0
58 78
59 def run(self, velocity, location): 79 def run(self, velocity, location):
80 """
81 Start the projectile on it's path.
82
83 @param velocity: The starting velocity of the projectile
84 @type velocity: L{fife.DoublePoint}
85 @param location: The location to create the projectile
86 @type location: L{fife.Location}
87
88 """
60 if not self._running: 89 if not self._running:
61 self._velocity = velocity 90 self._velocity = velocity
62 self._velocity.x /= self._xscale 91 self._velocity.x /= self._xscale
63 self._velocity.y /= self._yscale 92 self._velocity.y /= self._yscale
64 93
108 self._lastfired = 0 137 self._lastfired = 0
109 self._projectileVelocity = 0.75 138 self._projectileVelocity = 0.75
110 self._soundclip = None 139 self._soundclip = None
111 140
112 def fire(self, direction): 141 def fire(self, direction):
142 """
143 Fires the weapon in the specified direction.
144
145 @param direction: A normalized vector specifying the direction to fire the projectile
146 @type direction: L{fife.DoublePoint}
147 """
113 pass 148 pass
114 149
115 def _getProjectileVelocity(self): 150 def _getProjectileVelocity(self):
116 return self._projectileVelocity 151 return self._projectileVelocity
117 152