本文整理汇总了C++中Hero::getDirection方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::getDirection方法的具体用法?C++ Hero::getDirection怎么用?C++ Hero::getDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::getDirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/**************************************************************************************
UPDATE
**************************************************************************************/
void update() {
// Updating score
if(!end_game) {
score = "Score: " + to_string(score_points);
speed_string = "Speed: " + to_string(game_speed);
}
update_text (score_txtLabel, score.c_str());
update_text(speed_txtLabel, speed_string.c_str());
// Moving my objects
if(!camera.initial_rotation) {
for(int i=0; i<NUMBER_PARTICLES; i++)
snow[i].update(dt);
hero.setSpeed(game_speed);
hero.update(dt);
for(int i=0; i<score_points; i++) {
pines_collected[i].moveFollowing(dt);
pines_collected[i].setSpeed(game_speed);
}
for(int i=0; i<NUMBER_OF_MONSTERS; i++) {
monster[i].moveFollowing(dt);
monster[i].setSpeed(monster_speed_factor * game_speed);
}
}
// Setting Camera
camera.setDirection(hero.getDirection());
camera.setTarget(hero.getPosition());
camera.update();
// Setting cameras
if(!end_game) {
hero.setCamera(*camera.getViewMatrix());
game_floor.setCamera(*camera.getViewMatrix());
for(int i=0; i<NUMBER_OF_MONSTERS; i++)
monster[i].setCamera(*camera.getViewMatrix());
pine.setCamera(*camera.getViewMatrix());
for(int i=0; i<score_points; i++)
pines_collected[i].setCamera(*camera.getViewMatrix());
for(int i=0; i<NUMBER_PARTICLES; i++)
snow[i].setCamera(*camera.getViewMatrix());
}
}
示例2: sterowaniePostacia
void InputOutputHandler::sterowaniePostacia(Hero& hero)
{
// Sprawdzanie stanu kolizji
std::vector<bool> bStany = hero.getZnacznikiKolizji().getCollisionState();
// Blad - Kiedy ustawia sie na niewidoczny, detektor przestaje dzialac.
if (IsKeyDown( irr::KEY_KEY_Q ))
{
hero.getZnacznikiKolizji().setVisible(false);
}
if (IsKeyDown( irr::KEY_KEY_E ))
{
hero.getZnacznikiKolizji().setVisible(true);
}
konsola.setMessage(0, bStany[0] ? "left: true" : "left: false");
konsola.setMessage(1, bStany[1] ? "right: true" : "right: false");
konsola.setMessage(2, bStany[2] ? "forward: true" : "forward: false");
konsola.setMessage(3, bStany[3] ? "back: true" : "back: false");
konsola.setMessage(4, bStany[4] ? "up: true" : "up: false");
konsola.setMessage(5, bStany[5] ? "down: true" : "down: false");
if(!bStany[SideCollisionDetector::down])
hero.fallDown();
hero.getZnacznikiKolizji().setPosition(hero.getPosition(), hero.getRotation(), hero.getDirection());
hero.getZnacznikiKolizji().setRotation(hero.getRotation(), hero.getDirection());
if ( IsKeyDown( klawiszSkoku ) && !hero.getJumpState() && bStany[SideCollisionDetector::down] )
{
hero.setJumpState(true);
hero.stopFallingDown();
}
else if (bStany[SideCollisionDetector::down] || bStany[SideCollisionDetector::up])
hero.setJumpState(false);
if(hero.getJumpState())
hero.jump();
int player_direction = 0;
if ( IsKeyDown( irr::KEY_KEY_W ) )
player_direction |= FORWARD;
if ( IsKeyDown( irr::KEY_KEY_S ) )
player_direction |= BACKWARD;
if ( IsKeyDown( irr::KEY_KEY_A ) )
player_direction |= LEFT;
if ( IsKeyDown( irr::KEY_KEY_D ) )
player_direction |= RIGHT;
//nic się nie zmieniło
if(player_direction == 0) {
if (hero.getBezwladnosc() <= 0) hero.move(STAND, FORWARD);
else hero.decelerate();
hero.getZnacznikiKolizji().setPosition(hero.getPosition(), hero.getRotation(), hero.getDirection());
hero.getZnacznikiKolizji().setRotation(hero.getRotation(), hero.getDirection());
moveCameraControl();
hero.rotate(direction - 90);
return;
}
else {
hero.setBezwladnosc(1);
hero.resetAnimAndSpeed();
hero.setDirection(static_cast<DIRECTION>(player_direction));
hero.getZnacznikiKolizji().setPosition(hero.getPosition(), hero.getRotation(), hero.getDirection());
hero.getZnacznikiKolizji().setRotation(hero.getRotation(), hero.getDirection());
hero.move(WALK, hero.getDirection());
moveCameraControl();
}
hero.rotate(direction - 90);
}