From 18f134304c0c6181668a0a8c22289fcaeb472432 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 29 Dec 2012 10:22:19 +0000 Subject: BGE: Adding a jumpCount to KX_CharacterWrapper. This can be used to have different logic for a single jump versus a double jump. For example, a different animation for the second jump. --- source/gameengine/Ketsji/KX_CharacterWrapper.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/gameengine/Ketsji/KX_CharacterWrapper.cpp') diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp index dfd19a0d2bd..64bbbb7d344 100644 --- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp +++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp @@ -46,6 +46,7 @@ PyAttributeDef KX_CharacterWrapper::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("onGround", KX_CharacterWrapper, pyattr_get_onground), KX_PYATTRIBUTE_RW_FUNCTION("gravity", KX_CharacterWrapper, pyattr_get_gravity, pyattr_set_gravity), KX_PYATTRIBUTE_RW_FUNCTION("maxJumps", KX_CharacterWrapper, pyattr_get_max_jumps, pyattr_set_max_jumps), + KX_PYATTRIBUTE_RO_FUNCTION("jumpCount", KX_CharacterWrapper, pyattr_get_jump_count), { NULL } //Sentinel }; @@ -99,6 +100,14 @@ int KX_CharacterWrapper::pyattr_set_max_jumps(void *self_v, const KX_PYATTRIBUTE self->m_character->SetMaxJumps((int)param); return PY_SET_ATTR_SUCCESS; } + +PyObject *KX_CharacterWrapper::pyattr_get_jump_count(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_CharacterWrapper* self = static_cast(self_v); + + return PyLong_FromLong(self->m_character->GetJumpCount()); +} + PyMethodDef KX_CharacterWrapper::Methods[] = { KX_PYMETHODTABLE_NOARGS(KX_CharacterWrapper, jump), {NULL,NULL} //Sentinel -- cgit v1.2.3