本文整理汇总了C++中Tile::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::GetType方法的具体用法?C++ Tile::GetType怎么用?C++ Tile::GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void Map::Render(const SVector2& offset, OtherPlayers& otherPlayers) {
// Used in bounding box checks later
sOffset = offset;
int tiles = mMapData.GetTileAmount();
SGE::Graphics_DebugUsageBegin("Ground");
// Render Ground
for (int a = 0; a < tiles; ++a) {
GroundTile* pTile = &mMapData.mLayer1[a];
int type = pTile->GetType();
if (type) {
const SVector2& pos = pTile->GetPosition();
mSprites[type].SetPosition(pos + offset);
mSprites[type].Render();
}
}
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("MaskItems");
// Render Mask
for (int a = 0; a < tiles; ++a) {
Tile* pTile = &mMapData.mLayer2[a];
int type = pTile->GetType();
if (type) {
const SVector2& pos = pTile->GetPosition();
mSprites[type].SetPosition(pos + offset);
mSprites[type].Render();
}
// Render Items
if (mMapData.mLayer1[a].GetItemImageNumber() > 0 && GetItemActive(a)) {
SVector2 pos = SVector2(mMapData.mLayer1[a].GetPosition().y,
mMapData.mLayer1[a].GetPosition().x); // Bug
int type = mMapData.mLayer1[a].GetItemImageNumber();
if (type > 0 && type < mNumberOfItems) {
mItemSprites[type].mSprite.SetPosition(pos + offset);
mItemSprites[type].mSprite.Render();
}
}
}
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("NPCs");
// Render NPCS
for (int a = 0; a < mNumberOfNPCS; ++a) {
mNPCS[a]->Render(offset);
}
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("Players");
// Render Character
mCharacter.Render(offset);
// Render other players
otherPlayers.Render(offset);
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("Extras");
// Render Extra
for (int a = 0; a < tiles; ++a) {
SVector2 pos = mMapData.mLayer3[a].GetPosition();
int type = mMapData.mLayer3[a].GetType();
mSprites[type].SetPosition(pos + offset);
mSprites[type].Render();
}
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("Fringe");
// Render Fringe
for (int a = 0; a < tiles; ++a) {
SVector2 pos = mMapData.mLayer4[a].GetPosition();
int type = mMapData.mLayer4[a].GetType();
mSprites[type].SetPosition(pos + offset);
mSprites[type].Render();
}
SGE::Graphics_DebugUsageEnd();
SGE::Graphics_DebugUsageBegin("WeatherPaths");
mWeather.Render(offset);
mPathFinding.Render(offset);
SGE::Graphics_DebugUsageEnd();
}
示例2: 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;
}