diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2010-10-11 14:47:20 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2010-10-11 14:47:20 +0400 |
commit | 4814ffa07bbc8b55c60e540e7db70a18b2f3e992 (patch) | |
tree | ac8896389acc6c7ee85045f16f858ed04edd5f4a /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | e444c777145ccf297bc00f8e4690b78ed4ea85c9 (diff) |
BGE object.life - gives you the life countdown for temporary objects.
Whenever using AddObject actuator, this feature gives you control over morbid events (a.k.a. trigger events before the object ends).
Demo file here:
http://blenderecia.orgfree.com/blender/tmp/cube_life.blend
Feature implemented as part of the BGE development workshop in BlenderPRO 2010 - Fortaleza, Brazil
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6d83284379e..bbb17cd1df9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1496,6 +1496,7 @@ PyMethodDef KX_GameObject::Methods[] = { PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", KX_GameObject, pyattr_get_name), KX_PYATTRIBUTE_RO_FUNCTION("parent", KX_GameObject, pyattr_get_parent), + KX_PYATTRIBUTE_RO_FUNCTION("life", KX_GameObject, pyattr_get_life), KX_PYATTRIBUTE_RW_FUNCTION("mass", KX_GameObject, pyattr_get_mass, pyattr_set_mass), KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min), KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMax", KX_GameObject, pyattr_get_lin_vel_max, pyattr_set_lin_vel_max), @@ -1787,6 +1788,19 @@ PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE Py_RETURN_NONE; } +PyObject* KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + + CValue *life = self->GetProperty("::timebomb"); + if (life) + // this convert the timebomb seconds to frames, hard coded 50.0 (assuming 50fps) + // value hardcoded in KX_Scene::AddReplicaObject() + return PyFloat_FromDouble(life->GetNumber() * 50.0); + else + Py_RETURN_NONE; +} + PyObject* KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); |