本文整理汇总了C++中TileSet::GetTileRect方法的典型用法代码示例。如果您正苦于以下问题:C++ TileSet::GetTileRect方法的具体用法?C++ TileSet::GetTileRect怎么用?C++ TileSet::GetTileRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileSet
的用法示例。
在下文中一共展示了TileSet::GetTileRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTilesetFromTileId
void j1Map::Draw()
{
if(map_loaded == false)
return;
p2List_item<MapLayer*>* item = data.layers.start;
for(; item != NULL; item = item->next)
{
MapLayer* layer = item->data;
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
}
示例2: GetTilesetFromTileId
void j1Map::Draw()
{
if(map_loaded == false)
return;
//STL CHANGE
list<MapLayer*>::iterator item = data.layers.begin();
for(; item != data.layers.end(); ++item)
{
MapLayer* layer = *item;
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
}
示例3: MapToWorld
void j1Map::Draw()
{
if(map_loaded == false)
return;
// TODO 5: Prepare the loop to draw all tilesets + Blit
MapLayer* layer = data.layers.start->data;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
// TODO 10(old): Complete the draw function
TileSet* tileset = data.tilesets.start->data;
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
示例4: if
void j1Map::Draw()
{
if(map_loaded == false)
return;
//STL CHANGE
//NOTE: well
//Camera Culling
//----------------------
SDL_Rect cam = App->render->camera;
//----------------------
list<MapLayer*>::iterator item = data.layers.begin();
for(; item != data.layers.end(); ++item)
{
MapLayer* layer = *item;
//NOTE: when drawing navigation map, framerate drops to the half
if (!App->debug)
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
//NOTE: Maybe this has to be implemented on Render.cpp
//NOTE: changing the offset of the tiles because Ric cheated with the original, think about make it general for any map
//NOTE: because of test sake
//----------------------
if (layer->name == "Background")
App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 + tileset->offset_x, pos.y, &r);
else if (layer->name == "Navigation")
App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 , pos.y, &r);
//----------------------
}
}
}
}
}
示例5: GetTilesetFromTileId
void j1Map::Draw()
{
if(map_loaded == false)
return;
// TODO 4: Make sure we draw all the layers and not just the first one
p2List_item<MapLayer*>* layer = data.layers.start;
while (layer)
{
//This makes appear the Navigation Layer
if (layer->data->name == "Meta" && App->input->GetKey(SDL_SCANCODE_I) == KEY_DOWN)
{
if (layer->data->properties.GetPropertyValue("Draw") == 0)
layer->data->properties.SetPropertyValue("Draw", 1);
else
layer->data->properties.SetPropertyValue("Draw", 0);
}
//------------------------------------
if (layer->data->properties.GetPropertyValue("Draw"))
{
for (int y = 0; y < data.height; ++y)
{
for (int x = 0; x < data.width; ++x)
{
int tile_id = layer->data->Get(x, y);
if (tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
if (tileset != NULL)
{
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x + tileset->offset_x, pos.y + tileset->offset_y, &r);
}
}
}
}
}
layer = layer->next;
}
}