• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TileSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TileSet的典型用法代码示例。如果您正苦于以下问题:C++ TileSet类的具体用法?C++ TileSet怎么用?C++ TileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TileSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:35,代码来源:lua_TileSet.cpp


示例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);
				}
			}
		}
	}
}
开发者ID:thedoctormarc,项目名称:Dev_Repos,代码行数:32,代码来源:j1Map.cpp


示例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;
}
开发者ID:bran921007,项目名称:GD,代码行数:31,代码来源:TileMapTools.cpp


示例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);
				}
			}
		}
	}
}
开发者ID:JaviSaba7,项目名称:Pixel_Mirror--Diablo_II,代码行数:32,代码来源:j1Map.cpp


示例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);
			}
		}
	}
}
开发者ID:AlexisCosano,项目名称:Development,代码行数:26,代码来源:j1Map.cpp


示例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;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:34,代码来源:lua_TileSet.cpp


示例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;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:31,代码来源:lua_TileSet.cpp


示例8: BuildMovementMap

MovementMap::MovementMap(std::string file, const TileSet& tileSet)
{
    tileWidth = tileSet.GetTileWidth();
    tileHeight = tileSet.GetTileHeight();
    currentLayer = 0;

    BuildMovementMap(file);
}
开发者ID:imota,项目名称:IDJ_Godheim,代码行数:8,代码来源:MovementMap.cpp


示例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;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:55,代码来源:lua_TileSet.cpp


示例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;
}
开发者ID:bran921007,项目名称:GD,代码行数:55,代码来源:TileMapTools.cpp


示例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();
 }
开发者ID:nanathia,项目名称:tenninoboru_ketui,代码行数:12,代码来源:TileSetManager.cpp


示例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);
 }
开发者ID:nanathia,项目名称:tenninoboru_ketui,代码行数:12,代码来源:TileSetManager.cpp


示例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);
						
					
					//----------------------
				}
			}
		}
	}
	
}
开发者ID:joeyGumer,项目名称:Pixel_Mirror--Diablo_II,代码行数:53,代码来源:j1Map.cpp


示例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);
    }
}
开发者ID:ArduboyGameDevelopers,项目名称:PixelSpaceOdyssey,代码行数:14,代码来源:Tileset.cpp


示例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];
};
开发者ID:iliis,项目名称:A10,代码行数:15,代码来源:a10_game.cpp


示例16: SimpleCompaction

int WangTiles::SimpleCompaction(const TileSet & tileSet,
                                vector< vector<Tile> > & result)
{
    const int numTiles = tileSet.NumTiles();

    const int numHColors = tileSet.NumHColors();
    const int numVColors = tileSet.NumVColors();
    const int numTilesPerColor = tileSet.NumTilesPerColor();
    
    // find the best aspect ratio
    const int maxFactor = floor(sqrt(numTiles));

    const int height = numVColors*numVColors;
    const int width = numHColors*numHColors*numTilesPerColor;

    {
        result = vector< vector<Tile> > (height);

        for(int i = 0; i < result.size(); i++)
        {
            result[i] = vector<Tile>(width);
        }
    }

    {
        int i = 0; int j = 0;
        for(int e1 = 0; e1 < numVColors; e1++)
            for(int e3 = 0; e3 < numVColors; e3++)
                for(int e0 = 0; e0 < numHColors; e0++)
                    for(int e2 = 0; e2 < numHColors; e2++)
                    {
                        const vector<Tile> & tiles = tileSet.Tiles(e0, e1, e2, e3);

                        for(int k = 0; k < tiles.size(); k++)
                        {
                            result[i][j] = tiles[k];

                            j++;

                            if(j >= result[i].size())
                            {
                                i++; j = 0;
                            }
                        }
                    }
    }
    
    // done 
    return 1;
}
开发者ID:1iyiwei,项目名称:tile-texture-map,代码行数:50,代码来源:WangTiles.cpp


示例17: lua_TileSet_setTileSource

static int lua_TileSet_setTileSource(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 4:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                lua_type(state, 2) == LUA_TNUMBER &&
                lua_type(state, 3) == LUA_TNUMBER &&
                (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
            {
                // Get parameter 1 off the stack.
                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);

                // Get parameter 2 off the stack.
                unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);

                // Get parameter 3 off the stack.
                bool param3Valid;
                gameplay::ScriptUtil::LuaArray<Vector2> param3 = gameplay::ScriptUtil::getObjectPointer<Vector2>(4, "Vector2", true, &param3Valid);
                if (!param3Valid)
                {
                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'.");
                    lua_error(state);
                }

                TileSet* instance = getInstance(state);
                instance->setTileSource(param1, param2, *param3);
                
                return 0;
            }

            lua_pushstring(state, "lua_TileSet_setTileSource - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 4).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:49,代码来源:lua_TileSet.cpp


示例18: assertion

void Map::ForEachReachableTile( const Unit* unit, ForEachReachableTileCallback callback )
{
    assertion( unit, "Cannot find reachable tiles for null Unit!" );
    assertion( callback.IsValid(), "Cannot call invalid callback on reachable tiles!" );

    // Find all reachable tiles for the Unit.
    TileSet reachableTiles;
    FindReachableTiles( unit, reachableTiles );

    for( auto it = reachableTiles.begin(); it != reachableTiles.end(); ++it )
    {
        // Invoke the callback on all reachable tiles.
        callback.Invoke( *it, unit );
    }
}
开发者ID:hydraskillz,项目名称:AndroidWars,代码行数:15,代码来源:Map.cpp


示例19: Q_ASSERT

void EditorState::setTileSetIndex(int tileSetIndex)
{
    Q_ASSERT(tileSetIndex >= 0 && tileSetIndex < _tiles.size());
    _tileSetIndex = tileSetIndex;
    
    TileSet *tileSet = currentTileSet();
    
    PgmPtr *tiles = (PgmPtr *)malloc(tileSet->tileCount() * sizeof(PgmPtr));
    for (int i = 0; i < tileSet->tileCount(); ++i)
    {
        TileImage *tile = tileSet->getTileImage(i);
        PgmMem *tileMem = new PgmMem(tile->image());
        tiles[i] = tileMem->dataCopy();
        tileMem->release();
    }
    tileMap.tiles = tiles;
}
开发者ID:ArduboyGameDevelopers,项目名称:PixelSpaceOdyssey,代码行数:17,代码来源:EditorState.cpp


示例20: blitTile

void
GameView::drawMap(Surface &window)
{
    TileSet * ts = TileInterface::getTileSet();
    unsigned long world_x;
    unsigned long world_y;
    unsigned short map_x;
    unsigned short map_y;
    
    WorldViewInterface::getMainCamera()->getViewStart(window.getWidth(), window.getHeight(),
                              &world_x, &world_y);
    MapInterface::pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
        
    unsigned short tile_size = ts->getTileXsize();
    
    long partial_y = world_y % tile_size;
    int y = 0;
    if ( partial_y )
    {
        y -= partial_y;
    }
    
    long partial_x = world_x % tile_size;
    int start_x = 0;
    if ( partial_x )
    {
        start_x -= partial_x;
    }
    
    unsigned int tile = 0;
    
    WorldMap * map = MapInterface::getMap();
    
    unsigned short tmx;
    
    for ( ; y < (int)window.getHeight(); y += tile_size )
    {
        tmx = map_x;
        for ( int x = start_x; x < (int)window.getWidth(); x += tile_size )
        {
            tile = map->getValue(tmx++, map_y);
            blitTile(window, tile, x, y);
        }
        map_y ++;
    }
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:46,代码来源:GameView.cpp



注:本文中的TileSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TileSource类代码示例发布时间:2022-05-31
下一篇:
C++ TilePtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap