本文整理汇总了C++中Door::getRigidBody方法的典型用法代码示例。如果您正苦于以下问题:C++ Door::getRigidBody方法的具体用法?C++ Door::getRigidBody怎么用?C++ Door::getRigidBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Door
的用法示例。
在下文中一共展示了Door::getRigidBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Player::update(float deltaTime){
getRigidBody()->activate();
// modifying the speed based on the movement mode
if (inputHandler.isKeyDown(KEY_LCONTROL)){
// stealth movement
_mod = 2.0f;
}
else
// normal movement
_mod = 5.0f;
if (inputHandler.isKeyDown(KEY_LSHIFT))
_mod *= 2.0f;
//make noise unless crouched, more when sprinting
if (inputHandler.isKeyDown(KEY_LSHIFT) && (inputHandler.isKeyDown(KEY_KEY_W) || inputHandler.isKeyDown(KEY_KEY_A) || inputHandler.isKeyDown(KEY_KEY_S) || inputHandler.isKeyDown(KEY_KEY_D))){
_noiseAllowance -= 0.020f;
}
else if (!inputHandler.isKeyDown(KEY_LCONTROL) && (inputHandler.isKeyDown(KEY_KEY_W) || inputHandler.isKeyDown(KEY_KEY_A) || inputHandler.isKeyDown(KEY_KEY_S) || inputHandler.isKeyDown(KEY_KEY_D))){
_noiseAllowance -= 0.005f;
}
/* SETTING UP THE DIRECTION MATRIX */
// preparing the matrix
matrix4 mat0;
mat0.setRotationAxisRadians(_yaw, vector3df(0, 1, 0));
matrix4 mat1;
mat1.setRotationAxisRadians(_pitch, vector3df(1, 0, 0));
matrix4 mat = IdentityMatrix;
mat = mat0 * mat1;
// transform direction vectors based on the orientation of the player
vector3df backward(0.0f, 0.0f, -1.0f);
vector3df toLeft(-1.0f, 0.0f, .0f);
vector3df toRight(1.0f, 0.0f, 0.0f);
vector3df forward(0.0f, 0.0f, 1.0f);
vector3df up(0.0f, 1.0f, 0.0f);
mat.transformVect(forward);
mat.transformVect(backward);
mat.transformVect(toLeft);
mat.transformVect(toRight);
setForward(forward);
setUp(up);
/* MOVEMENT */
// setting key press events
if (inputHandler.isKeyDown(KEY_KEY_D) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(toRight.X, 0.0f, -toRight.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_A) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(toLeft.X, 0.0f, -toLeft.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_S) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-backward.X, 0.0f, backward.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_W) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-forward.X, 0.0f, forward.Z)*_mod);
}
// setting double key press events
if (inputHandler.isKeyDown(KEY_KEY_W) && inputHandler.isKeyDown(KEY_KEY_A) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-forward.X + toLeft.X, 0.0f, forward.Z - toLeft.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_W) && inputHandler.isKeyDown(KEY_KEY_D) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-forward.X + toRight.X, 0.0f, forward.Z - toRight.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_S) && inputHandler.isKeyDown(KEY_KEY_A) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-backward.X + toLeft.X, 0.0f, backward.Z - toLeft.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_KEY_S) && inputHandler.isKeyDown(KEY_KEY_D) && isDown()) {
this->getRigidBody()->setLinearVelocity(btVector3(-backward.X + toRight.X, 0.0f, backward.Z - toRight.Z)*_mod);
}
// jump!
if (inputHandler.isKeyDown(KEY_SPACE) && !inputHandler.wasKeyDown(KEY_SPACE) && isDown() && !isStealthActive()) {
getRigidBody()->setLinearVelocity(btVector3(up.X, up.Y*_mod, up.Z));
game.getAudioEngine()->play2D("sounds/common/jump.wav");
_noiseAllowance -= 2.0f;
}
// TODO: fix the jumping and moving forward feature
if (inputHandler.isKeyDown(KEY_SPACE) && inputHandler.isKeyDown(KEY_KEY_W) && isDown() && !isStealthActive()) {
getRigidBody()->setLinearVelocity(btVector3(up.X - forward.X, up.Y, up.Z + forward.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_SPACE) && inputHandler.isKeyDown(KEY_KEY_S) && isDown() && !isStealthActive()) {
getRigidBody()->setLinearVelocity(btVector3(up.X - backward.X, up.Y, up.Z + backward.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_SPACE) && inputHandler.isKeyDown(KEY_KEY_A) && isDown() && !isStealthActive()) {
getRigidBody()->setLinearVelocity(btVector3(up.X + toLeft.X, up.Y, up.Z - toLeft.Z)*_mod);
}
if (inputHandler.isKeyDown(KEY_SPACE) && inputHandler.isKeyDown(KEY_KEY_D) && isDown() && !isStealthActive()) {
getRigidBody()->setLinearVelocity(btVector3(up.X + toRight.X, up.Y, up.Z - toRight.Z)*_mod);
}
//.........这里部分代码省略.........