本文整理汇总了C++中Platform::setState方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::setState方法的具体用法?C++ Platform::setState怎么用?C++ Platform::setState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::setState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckCollision
void Game::CheckCollision() {
// TODO all X and Y coords to absolute (level) values as opposed to screen values refactor this
std::map<std::pair<int, int>, Entity*>* entities = level->getEntities();
for (std::map<std::pair<int, int>, Entity*>::iterator i = entities->begin(); i != entities->end(); i++) {
Entity* entity = i->second;
Platform* p = dynamic_cast<Platform*>(entity);
int levelBlockX = i->first.second;
int levelBlockY = i->first.first;
if (p != NULL && p->getState() == dislodged) {
p->setYOffset(p->getYOffset() + 5); //TODO needs to be a variable
int currentLevelBlockX = levelBlockX;
int currentLevelBlockY = levelBlockY + (p->getYOffset() + 50) / Level::BLOCK_HEIGHT_PX;
if (level->getLevelCodeByBlock(currentLevelBlockX, currentLevelBlockY) == '_') {
p->setState(broken);
level->setLevelCodeByBlock(currentLevelBlockX,currentLevelBlockY, '$');
level->setLevelCodeByBlock(levelBlockX, levelBlockY, ' ');
}
else {
p->setY(int(p->getY() + 5) % (Level::BLOCK_HEIGHT_PX * Level::SCENE_HEIGHT_BLK));
//p->setY((levelBlockY - level->getSceneY()) * Level::BLOCK_HEIGHT_PX + p->getYOffset() - p->getAnim()->getSheet()->getFrameHeight());
if (!level->inScene(levelBlockX, levelBlockY) && level->inScene(currentLevelBlockX, currentLevelBlockY)) {
p->Animate(&graphics);
}
}
}
}
collision->CheckPrinceCollision(prince);
CheckCombatCollision();
}