当前位置: 首页>>代码示例>>C++>>正文


C++ Tile::SetType方法代码示例

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


在下文中一共展示了Tile::SetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetTileInfo

void MapData::SetTileInfo(float x, float y, int tile, int layer, int id) {
    Tile* temp;
    switch (layer) {
    case 1: {
        temp = &mLayer1[tile];
        break;
    }
    case 2: {
        temp = &mLayer2[tile];
        break;
    }
    case 3: {
        temp = &mLayer3[tile];
        break;
    }
    case 4: {
        temp = &mLayer4[tile];
        break;
    }
    default: {

        break;
    }
    }
    temp->SetPosition(SVector2(x, y));
    temp->SetType(id);
}
开发者ID:Equinox-,项目名称:Mirage--,代码行数:27,代码来源:MapData.cpp

示例2: Initialize

void MapLayerTiled::Initialize(u32 tilesWidth, u32 tilesHeight)
{
	tilesWidth = tilesWidth < iViewTilesWidth ? iViewTilesWidth : tilesWidth;
	tilesHeight = tilesHeight < iViewTilesHeight ? iViewTilesHeight : tilesHeight;

	if (pTiles)
	{
		for (u32 y = 0; y < iTilesHeight; y++)
		{
			for (u32 x = 0; x < iTilesWidth; x++)
			{
				Delete(TILE(x, y));
			}
		}

		pMemoryManager->Free(pTiles);
	}

	iTilesWidth = tilesWidth;
	iTilesHeight = tilesHeight;
	pTiles = (Tile **)pMemoryManager->Alloc(iTilesWidth * iTilesHeight * sizeof(Tile *), pDefaultPool, "Grid", "MapLayerTiled");

	for (u32 y = 0; y < iTilesHeight; y++)
	{
		for (u32 x = 0; x < iTilesWidth; x++)
		{
			Tile *tile = New(Tile);
			TILE(x, y) = tile;

			if (pTileData)
				tile->SetType(pTileData[(x) + (iTilesWidth * (y))]);
			else
				tile->SetType(0);
		}
	}

	iMapWidth = ptiTileSize.x * iTilesWidth;
	iMapHeight = ptiTileSize.y * iTilesHeight;
	iViewWidth = ptiTileSize.x * iViewTilesWidth;
	iViewHeight = ptiTileSize.y * iViewTilesHeight;

	this->UpdateTiles(0, 0);
}
开发者ID:ggj,项目名称:papillon,代码行数:43,代码来源:maplayertiled.cpp

示例3: SetTileData

void MapLayerTiled::SetTileData(const u32 *data)
{
	pTileData = data;

	if (pTiles)
	{
		for (u32 y = 0; y < iTilesHeight; y++)
		{
			for (u32 x = 0; x < iTilesWidth; x++)
			{
				Tile *tile = TILE(x, y);

				if (pTileData)
					tile->SetType(pTileData[(x) + (iTilesWidth * (y))]);
				else
					tile->SetType(0);
			}
		}
	}
}
开发者ID:ggj,项目名称:papillon,代码行数:20,代码来源:maplayertiled.cpp

示例4: PostProcessMap

    void Generator::PostProcessMap(Map& map)
    {
        // Sort tiles by connectivity
        std::map<std::pair<unsigned int, unsigned int>, unsigned int> tiles;
        unsigned int id = 0;
        for (Map::TileIterator itr = map.GetTilesBegin(); itr != map.GetTilesEnd(); ++itr)
        {
            if (!itr->second->IsBlocked())
            {
                std::map<std::pair<unsigned int, unsigned int>, unsigned int>::iterator itr2 = tiles.find(itr->first);
                if (itr2 == tiles.end())
                {
                    tiles.insert(std::make_pair(itr->first, id));
                    PostProcessTile(map, *itr->second, tiles, id);
                    ++id;
                }
            }
        }

        // Find largest connected area
        std::vector<unsigned int> count;
        for (unsigned int i = 0; i != id; ++i)
        {
            count.push_back(0);
        }
        for (std::map<std::pair<unsigned int, unsigned int>, unsigned int>::iterator itr = tiles.begin(); itr != tiles.end(); ++itr)
        {
            ++count[itr->second];
        }
        unsigned int max = 0;
        unsigned int max_id = 0;
        for (unsigned int i = 0; i != id; ++i)
        {
            if (count[i] > max)
            {
                max = count[i];
                max_id = i;
            }
        }

        // Blcok all tiles that aren't connected to the largest connected area
        for (std::map<std::pair<unsigned int, unsigned int>, unsigned int>::iterator itr = tiles.begin(); itr != tiles.end(); ++itr)
        {
            if (itr->second != max_id)
            {
                Tile* tile = map.GetTile(itr->first.first, itr->first.second);
                tile->SetType(TT_FOREST);
            }
        }
    }
开发者ID:LastRitesGames,项目名称:Coatl,代码行数:50,代码来源:coatl_gen.cpp

示例5: CreateMap

    Map* Generator::CreateMap(Game& game, unsigned int width, unsigned int height, unsigned int tile_width, unsigned int tile_height)
    {
        Map* map = new Map(game, width, height, tile_width, tile_height);

        // Generate water tiles on the edge of the map
        noise::module::Perlin perlin;
        perlin.SetSeed(Random::UInt());
        perlin.SetNoiseQuality(noise::QUALITY_BEST);
        perlin.SetLacunarity(1.0f);
        Tile* tile;
        for (unsigned int x = 0; x != width; ++x)
        {
            double size = abs(perlin.GetValue(x * .02, 0, 0) * 16.0);
            for (unsigned int i = 0; i < size + 16; ++i)
            {
                tile = map->GetTile(x, i);
                if (tile)
                {
                    tile->SetType(TT_WATER);
                }
                tile = map->GetTile(x, height - i - 1);
                if (tile)
                {
                    tile->SetType(TT_WATER);
                }
            }
        }
        for (unsigned int y = 0; y != height; ++y)
        {
            double size = abs(perlin.GetValue(0, y * .02, 0) * 16.0);
            for (unsigned int i = 0; i < size + 16; ++i)
            {
                tile = map->GetTile(i, y);
                if (tile)
                {
                    tile->SetType(TT_WATER);
                }
                tile = map->GetTile(width - i - 1, y);
                if (tile)
                {
                    tile->SetType(TT_WATER);
                }
            }
        }

        // Generate forest or grass tiles on remaining tiles
        perlin.SetSeed(Random::UInt());
        perlin.SetNoiseQuality(noise::QUALITY_BEST);
        perlin.SetLacunarity(1.0f);
        for (unsigned int x = 1; x != width; ++x)
        {
            for (unsigned int y = 1; y != height; ++y)
            {
                tile = map->GetTile(x, y);
                if (tile->GetType() != TT_WATER)
                {
                    double value = perlin.GetValue(x * .02, y * .02, 0);
                    if (value <= -.3 || value >= .3)
                    {
                        tile->SetType(TT_FOREST);
                    }
                    else
                    {
                        tile->SetType(TT_GRASS);
                    }
                }
            }
        }

        // Remove unreachable tiles
        PostProcessMap(*map);

        return map;
    }
开发者ID:LastRitesGames,项目名称:Coatl,代码行数:74,代码来源:coatl_gen.cpp


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