Mercurial > fife-parpg
diff demos/shooter/scripts/common/baseobject.py @ 477:6b33d80b468b
Projectiles are now part of the scene.
Cleaned up the scene update() function.
Moved garbage collection to the beginning of the frame.
Introduced global object types.
Projectiles now only check for collisions in a limited number of scene nodes rather than the entire screen.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 22 Apr 2010 19:52:34 +0000 |
parents | 78a1eb57c074 |
children | ab28994820dd |
line wrap: on
line diff
--- a/demos/shooter/scripts/common/baseobject.py Thu Apr 22 01:18:44 2010 +0000 +++ b/demos/shooter/scripts/common/baseobject.py Thu Apr 22 19:52:34 2010 +0000 @@ -25,6 +25,14 @@ from scripts.common.helpers import normalize from scripts.common.helpers import Rect + +SHTR_DEFAULT = 0 +SHTR_PLAYER = 1 +SHTR_LASTBOSS = 2 +SHTR_PROJECTILE = 3 +SHTR_ENEMYSHIP = 4 + + class SpaceObject(object): def __init__(self, scene, name, findInstance=True): self._scene = scene @@ -39,6 +47,7 @@ self._running = False self._changedPosition = False self._scenenodeid = -1 + self._type = SHTR_DEFAULT if findInstance: self._instance = self._layer.getInstance(self._name) @@ -113,9 +122,6 @@ def removeFromScene(self): self._scene.queueObjectForRemoval(self) -# if self._instance: -# self._layer.deleteInstance(self._instance) -# self._instance = None def _isRunning(self): return self._running @@ -167,7 +173,14 @@ def _setNodeId(self, id): self._scenenodeid = id + + def _getType(self): + return self._type + + def _setType(self, objtype): + self._type = objtype + type = property(_getType, _setType) width = property(_getW, _setW) height = property(_getH, _setH) boundingbox = property(_getBoundingBox)