本文整理汇总了C++中Tile::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::Draw方法的具体用法?C++ Tile::Draw怎么用?C++ Tile::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderFrame
void Engine::RenderFrame()
{
int cameraXOffset = camera->GetPosition().x, cameraYOffset = camera->GetPosition().y;
Tile* tile;
window->Clear();
bound = camera->GetTileBounds(tileSize);
int tmp = bound.GetHeight();
tmp++;
tmp--;
for(int y = 0, tileY = bound.Top; y < bound.GetHeight(); y++, tileY++)
{
for(int x = 0, tileX = bound.Left; x < bound.GetWidth(); x++, tileX++)
{
tile = graph->getTile(tileX,tileY);
tile->Draw( (x * tileSize) - cameraXOffset, (y * tileSize) - cameraYOffset, window);
}
}
window->Display();
}
示例2: 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();
}
示例3: Draw
void Level::Draw(bool actionMode, Vector2i camOffset, IntRect bounds, Vector2f camPos, RenderWindow* window)
{
int camOffsetX = camOffset.x;
int camOffsetY = camOffset.y;
//Variables: X & Y - how many tiles drawn, TILEX & TILEY - which tile being drawn
int x, y, tileX, tileY;
Tile* tile;
//Loop and draw each tile
for (y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
{
for (x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
{
//make sure tile location is within map
if (tileX < 0 || tileY < 0 || tileX >= map.size() || tileY >= map[0].size())
continue;
//get the tile being drawn
tile = map[tileX][tileY];
if(tile)
{
tile->Draw((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
if(selectedTile == tile)
{
DrawSelectBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
}
else if (targetedTile == tile)
{
DrawTargetBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
}
if(hoverTile == tile)
{
DrawHoverBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
}
if(actionMode && selectedTile && selectedTile->GetDomOccupant())
{
DrawMoveSprites((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, selectedTile->GetDomOccupant()->GetSpeed(), tile, window);
}
else if(actionMode)
{
DrawGridSprite((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
}
}
}
}
//Loop and draw each tile's occupants; this requires its own loop so that tiles don't get
//drawn over entities
for (y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
{
for (x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
{
//make sure tile location is within map
if (tileX < 0 || tileY < 0 || tileX >= map.size() || tileY >= map[0].size())
continue;
//get the tile whose occupants are to be drawn
tile = map[tileX][tileY];
if(tile)
{
tile->DrawOccupants(camPos.x, camPos.y, window);
}
}
}
}