Mercurial > fife-parpg
diff demos/shooter/scripts/weapons.py @ 448:5e2ec84902a7
Did a little re-factoring.
Introduced the scene graph for collision detection.
Changed the time scale to be accurate.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 01 Apr 2010 17:03:34 +0000 |
parents | 64676ea55472 |
children | 1cf56403347a |
line wrap: on
line diff
--- a/demos/shooter/scripts/weapons.py Wed Mar 31 21:13:07 2010 +0000 +++ b/demos/shooter/scripts/weapons.py Thu Apr 01 17:03:34 2010 +0000 @@ -22,22 +22,19 @@ # #################################################################### from fife import fife +from scripts.ships.shipbase import SpaceObject -class Projectile(object): +class Projectile(SpaceObject): def __init__(self, model, projectileName, layer, timeToLive): - self._model = model + super(Projectile, self).__init__(model, projectileName, layer, False) self._name = projectileName self._layer = layer - self._instance = None - self._velocity = None + self._obj = self._model.getObject(self._name, "http://www.fifengine.de/xml/tutorial") self._running = False self._ttl = timeToLive self._starttime = 0 - - self._xscale = self._layer.getCellGrid().getXScale() - self._yscale = self._layer.getCellGrid().getYScale() - + def create(self, location): self._instance = self._layer.createInstance(self._obj, location.getExactLayerCoordinates(), "bullet") fife.InstanceVisual.create(self._instance) @@ -58,12 +55,6 @@ self._layer.deleteInstance(self._instance) self._running = False - def _getLocation(self): - return self._instance.getLocation() - - def _setLocation(self, loc): - self._instance.setLocation(loc) - def _isRunning(self): return self._running @@ -83,7 +74,6 @@ else: self.destroy() - location = property(_getLocation,_setLocation) running = property(_isRunning) ttl = property(_getTTL)