本文整理汇总了C++中Platform::Animate方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::Animate方法的具体用法?C++ Platform::Animate怎么用?C++ Platform::Animate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::Animate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: DrawBackground
void Game::DrawBackground() {
int yOff = 0;
int xOff = 0;
//TODO this value is being reused in check collision move it in a common location or eliminate collision detection when drawing completely
int princeXOffset = 22;
for (int y = Level::SCENE_HEIGHT_BLK; y >= 0; y--) {
for (int x = 0; x <= Level::SCENE_WIDTH_BLK; x++) {
yOff = Level::BLOCK_HEIGHT_PX * y;
xOff = -Level::BLOCK_WIDTH_PX + Level::BLOCK_WIDTH_PX * x;
switch (level->getSceneCodeByBlock(y, x)) {
case '|':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
break;
case 'T':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
graphics.DrawSprite(xOff - 1, yOff - getSprite("columnBack")->height - 15, getSprite("columnBack"));
break;
case ']':
graphics.DrawSprite(xOff, yOff - getSprite("blockCornerRight")->height, getSprite("blockCornerRight"));
break;
case '_':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
break;
case '1':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
break;
case '~': {
std::map<std::pair<int, int>, Entity*>* entities = level->getEntities();
int blockX = level->getLevelBlockX(x);
int blockY = level->getLevelBlockY(y);
std::pair<int, int> platformKey = std::make_pair(blockY, blockX);
Entity* e = entities->at(platformKey);
Platform* p = dynamic_cast<Platform*>(e);
if (p != NULL) {
int currentLevelBlockX = blockX;
int currentLevelBlockY = blockY + (p->getYOffset() + 120) / Level::BLOCK_HEIGHT_PX;
if (level->inScene(currentLevelBlockX, currentLevelBlockY)) {
p->Animate(&graphics);
}
}
if (level->getSceneBlockXByCoord(prince->getMidX() - princeXOffset) == x &&
level->getSceneBlockYByCoord(prince->getMidY()) == y && prince->getState() != sJumping) {
p->Drop();
}
} break;
case 'H':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
break;
case '-':
if (level->getSceneCodeByCoord(prince->getMidX() - princeXOffset, prince->getMidY()) == '-') {
if (level->getSceneBlockXByCoord(prince->getMidX() - princeXOffset) == x &&
level->getSceneBlockYByCoord(prince->getMidY() == y) &&
prince->getState() != sJumping) {
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
}
else {
graphics.DrawSprite(xOff, yOff - getSprite("activate")->height, getSprite("activate"));
}
}
else {
graphics.DrawSprite(xOff, yOff - getSprite("activate")->height, getSprite("activate"));
}
break;
case '=':
if (level->getSceneCodeByCoord(prince->getMidX() - princeXOffset, prince->getMidY()) == '=') {
if (level->getSceneBlockXByCoord(prince->getMidX() - princeXOffset) == x &&
level->getSceneBlockYByCoord(prince->getMidY() == y) &&
prince->getState() != sJumping
) {
graphics.DrawSprite(xOff, yOff + 2 - getSprite("trap")->height, getSprite("trap"));
}
else {
graphics.DrawSprite(xOff, yOff - getSprite("trap")->height, getSprite("trap"));
}
}
else {
graphics.DrawSprite(xOff, yOff - getSprite("trap")->height, getSprite("trap"));
}
break;
case '*':
graphics.DrawSprite(xOff, yOff - getSprite("bricks")->height, getSprite("bricks"));
break;
case '/':
graphics.DrawSprite(xOff, yOff - getSprite("holyFloor")->height, getSprite("holyFloor"));
break;
case 'S':
graphics.DrawSprite(xOff, yOff - getSprite("deadSk")->height, getSprite("deadSk"));
break;
case 'G':
graphics.DrawSprite(xOff, yOff - getSprite("doorFrameBack")->height, getSprite("doorFrameBack"));
break;
case '#':
graphics.DrawSprite(xOff, yOff - getSprite("tileCornerLeft")->height, getSprite("tileCornerLeft"));
graphics.DrawSprite(xOff, yOff - getSprite("bricks")->height, getSprite("bricks"));
//.........这里部分代码省略.........