本文整理汇总了C++中TileSet类的典型用法代码示例。如果您正苦于以下问题:C++ TileSet类的具体用法?C++ TileSet怎么用?C++ TileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TileSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_TileSet_setOpacity
static int lua_TileSet_setOpacity(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
float param1 = (float)luaL_checknumber(state, 2);
TileSet* instance = getInstance(state);
instance->setOpacity(param1);
return 0;
}
lua_pushstring(state, "lua_TileSet_setOpacity - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 2).");
lua_error(state);
break;
}
}
return 0;
}
示例2: 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);
}
}
}
}
}
示例3: GenerateHitboxes
std::vector<Polygon2d> GenerateHitboxes(TileSet &tileSet, TileMap &tileMap)
{
std::vector<Polygon2d> hitboxes;
const int tileWidth = tileSet.tileSize.x;
const int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty())
return hitboxes;
for(int layer = 0; layer < 3; layer++)
{
for(int col = 0; col < tileMap.GetColumnsCount(); col++)
{
for(int row = 0; row < tileMap.GetRowsCount(); row++)
{
//Note : a hitbox is also added for empty/non-collidable tiles to ease the hitbox update when changing a tile
Polygon2d newPolygon;
if(tileMap.GetTile(layer, col, row) != -1 && tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).collidable)
{
newPolygon = tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).hitbox;
}
newPolygon.Move(col * tileWidth, row * tileHeight);
hitboxes.push_back(newPolygon);
}
}
}
return hitboxes;
}
示例4: 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);
}
}
}
}
}
示例5: 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);
}
}
}
}
示例6: lua_TileSet_getWidth
static int lua_TileSet_getWidth(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
TileSet* instance = getInstance(state);
float result = instance->getWidth();
// Push the return value onto the stack.
lua_pushnumber(state, result);
return 1;
}
lua_pushstring(state, "lua_TileSet_getWidth - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1).");
lua_error(state);
break;
}
}
return 0;
}
示例7: lua_TileSet_addRef
static int lua_TileSet_addRef(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
TileSet* instance = getInstance(state);
instance->addRef();
return 0;
}
lua_pushstring(state, "lua_TileSet_addRef - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1).");
lua_error(state);
break;
}
}
return 0;
}
示例8: BuildMovementMap
MovementMap::MovementMap(std::string file, const TileSet& tileSet)
{
tileWidth = tileSet.GetTileWidth();
tileHeight = tileSet.GetTileHeight();
currentLayer = 0;
BuildMovementMap(file);
}
示例9: lua_TileSet_draw
static int lua_TileSet_draw(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
TileSet* instance = getInstance(state);
unsigned int result = instance->draw();
// Push the return value onto the stack.
lua_pushunsigned(state, result);
return 1;
}
lua_pushstring(state, "lua_TileSet_draw - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TBOOLEAN)
{
// Get parameter 1 off the stack.
bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
TileSet* instance = getInstance(state);
unsigned int result = instance->draw(param1);
// Push the return value onto the stack.
lua_pushunsigned(state, result);
return 1;
}
lua_pushstring(state, "lua_TileSet_draw - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
lua_error(state);
break;
}
}
return 0;
}
示例10: GenerateVertexArray
sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
{
sf::VertexArray vertexArray(sf::Quads);
int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty())
return vertexArray;
for(int layer = 0; layer < 3; layer++)
{
for(int col = 0; col < tileMap.GetColumnsCount(); col++)
{
for(int row = 0; row < tileMap.GetRowsCount(); row++)
{
TileTextureCoords coords;
if(tileMap.GetTile(layer, col, row) != -1)
{
coords = tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row));
}
else
{
coords = tileSet.GetTileTextureCoords(0);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, row * tileHeight), coords.topLeft);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, (row + 1) * tileHeight), coords.bottomLeft);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, (row + 1) * tileHeight), coords.bottomRight);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, row * tileHeight), coords.topRight);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
}
}
}
return vertexArray;
}
示例11: getLocalGid
int TileSetManager::getLocalGid(int gid) const{
int size = (int)m_TileSet.size();
TileSet* set = 0;
for(int i = 1; i < size; i++){
if(m_TileSet[i]->getFirstGit() > gid){
set = m_TileSet[i-1];
break;
}
}
if(!set) set = m_TileSet[size-1];
return gid - set->getFirstGit();
}
示例12: drawTile
void TileSetManager::drawTile(GMSpriteBatch *s, const GMRect2D &dest, double radian, int gid) const{
int size = (int)m_TileSet.size();
TileSet* set = 0;
for(int i = 1; i < size; i++){
if(m_TileSet[i]->getFirstGit() > gid){
set = m_TileSet[i-1];
break;
}
}
if(!set) set = m_TileSet[size-1];
set->getImage()->draw(s, dest, radian, gid);
}
示例13: GetTilesetFromTileId
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);
//----------------------
}
}
}
}
}
示例14: sizeof
TileSet::TileSet(const TileSet &other, int scale)
{
_tileWidth = scale * other.tileWidth();
_tileHeight = scale * other.tileHeight();
_tileCount = other.tileCount();
_name = other.name();
_images = (TileImage **)malloc(_tileCount * sizeof(TileImage *));
for (int i = 0; i < _tileCount; ++i)
{
QImage tileImage = other.getTileImage(i)->image().scaled(_tileWidth, _tileHeight);
_images[i] = new TileImage(tileImage);
}
}
示例15: TileSet
//------------------------------------------------------------------------------
TileSet*
A10_Game::getTileset(string path)
{
if(this->tilesets.find(path) == this->tilesets.end())
{
TileSet* ts = new TileSet(kernel->graphicsMgr);
ts->loadFromFile(path);
this->tilesets[path] = ts;
return ts;
}
return this->tilesets[path];
};