本文整理汇总了C++中PlayerEntity::IsInMotion方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerEntity::IsInMotion方法的具体用法?C++ PlayerEntity::IsInMotion怎么用?C++ PlayerEntity::IsInMotion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerEntity
的用法示例。
在下文中一共展示了PlayerEntity::IsInMotion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void MainScreen::Update() {
Chamber * curChamber = CM->GetCurrentChamber();
PlayerEntity * player = CM->GetPlayer();
if ( player != 0 ) {
if ( !(player->IsInMotion()) ) { // && !(curChamber->HasEntityInMotion())
int numDirsPressed = (keysPressed[DOWN] ? 1 : 0) + (keysPressed[UP] ? 1 : 0) + (keysPressed[LEFT] ? 1 : 0) + (keysPressed[RIGHT] ? 1 : 0);
// interaction with environment
if ( keysToggled[INTERACT] && keysPressed[INTERACT] ) {
int dx = UTIL::DirToXAdjustment( player->GetDir() );
int dy = UTIL::DirToYAdjustment( player->GetDir() );
int curx = player->GetPos()->GetTileX();
int cury = player->GetPos()->GetTileY();
// check to see if there is an entity with the sygaldry property in the tile we are facing
TileEntity * sygaldryAble = curChamber->GetEntityWithPropertyInTile( "Sygaldry", Chamber::GetTileNumFromPos(curx + dx, cury + dy) );
if ( sygaldryAble != 0 ) {
// open the SygaldryScreen on that object
BaseScreen * bs = new SygaldryScreen( sygaldryAble );
bs->Init();
(ScreenManager::GetInstance()).PushGameScreen( bs );
}
} else if ( keysToggled[INVENTORY] && keysPressed[INVENTORY] ) {
// open up the inventory screen
BaseScreen * bs = new InventoryScreen();
bs->Init();
(ScreenManager::GetInstance()).PushGameScreen( bs );
} else if ( keysToggled[ALLEGRO_KEY_F] && keysPressed[ALLEGRO_KEY_F] ) {
int dx = UTIL::DirToXAdjustment( player->GetDir() );
int dy = UTIL::DirToYAdjustment( player->GetDir() );
int curx = player->GetPos()->GetTileX();
int cury = player->GetPos()->GetTileY();
std::list <TileEntity *> * tileEntityList = curChamber->GetEntitiesInTile( Chamber::GetTileNumFromPos(curx + dx, cury + dy) );
std::list < TileEntity * >::iterator iter;
for ( iter = tileEntityList->begin(); iter != tileEntityList->end(); ++iter ) {
(*iter)->OnInput( "OnHeated" );
}
} else if ( keysToggled[ALLEGRO_KEY_G] && keysPressed[ALLEGRO_KEY_G] ) {
int dx = UTIL::DirToXAdjustment( player->GetDir() );
int dy = UTIL::DirToYAdjustment( player->GetDir() );
int curx = player->GetPos()->GetTileX();
int cury = player->GetPos()->GetTileY();
std::list <TileEntity *> * tileEntityList = curChamber->GetEntitiesInTile( Chamber::GetTileNumFromPos(curx + dx, cury + dy) );
std::list < TileEntity * >::iterator iter;
for ( iter = tileEntityList->begin(); iter != tileEntityList->end(); ++iter ) {
(*iter)->OnInput( "OnChilled" );
}
} else if ( keysToggled[ALLEGRO_KEY_R] && keysPressed[ALLEGRO_KEY_R] ) {
int uid = curChamber->GetUID();
CM->ReloadChamber( uid );
CM->SetCurrentChamber( uid );
return;
} else if ( numDirsPressed == 1 ) {
int dx = 0;
int dy = 0;
if ( keysPressed[DOWN] ) {
dy = 1;
} else if ( keysPressed[UP] ) {
dy = -1;
} else if ( keysPressed[RIGHT] ) {
dx = 1;
} else if ( keysPressed[LEFT] ) {
dx = -1;
}
int desDir = UTIL::DirFromDelta(dx, dy);
if ( player->GetDir() != desDir ) {
player->SetDir( desDir );
} else {
int curx = player->GetPos()->GetTileX();
int cury = player->GetPos()->GetTileY();
int tx = curx + dx;
int ty = cury + dy;
// check if target is free
if ( curChamber->CanTileBeEntered( tx, ty ) ) {
curChamber->RegisterTileEntityInTile( player, tx, ty );
player->MoveWithAnimation( desDir, 24, PlayerEntity::MOVE::WALK );
}
else {
TileEntity * pushable = curChamber->GetEntityWithPropertyInTile( "MoveType", Chamber::GetTileNumFromPos( tx, ty) );
if ( pushable != 0 ) {
// we are pushing something
//.........这里部分代码省略.........