本文整理汇总了C++中Collision::RectCollide方法的典型用法代码示例。如果您正苦于以下问题:C++ Collision::RectCollide方法的具体用法?C++ Collision::RectCollide怎么用?C++ Collision::RectCollide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collision
的用法示例。
在下文中一共展示了Collision::RectCollide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderFrame
void Engine::RenderFrame()
{
Collision checker; //DELETE
//Camera offsets
int camOffsetX, camOffsetY;
Tile* tile;
window->clear();
//Get the tile bounds we need to draw
sf::IntRect bounds = camera->GetTileBounds(tileSize);
//Figure out how much to offset each tile
camOffsetX = camera->GetTileOffset(tileSize).x;
camOffsetY = camera->GetTileOffset(tileSize).y;
//Loop through and draw each tile
//We're keeping track of two variables in each loop. How many tiles
//we've drawn (x and y), and which tile on the map we're drawing (tileX
//and tileY)
player->ground = false;
for(int y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
{
for(int x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
{
tile = new Tile(TextureManager.GetTexture(0)); // background!
tile->Draw((x * tileSize) - camOffsetX, (y * tileSize) - camOffsetY, window);
//Get the tile
tile = currentLevel->GetTile(tileX, tileY);
if(tile){
tile->Draw((x * tileSize) - camOffsetX, (y * tileSize) - camOffsetY, window);
if(checker.RectCollide(sf::FloatRect((x * tileSize), (y * tileSize), tileSize, tileSize), sf::FloatRect((player->getPosition().left), (player->getPosition().top), tileSize, tileSize)) && tile->baseSprite.getTexture() == Tile(TextureManager.GetTexture(2)).baseSprite.getTexture()){
player->ground = true;
}
}
}
}
player->Draw(camOffsetX, camOffsetY, window);
window->display();
}