Fix sprites being indexed funky. Consolidated tile group code, broke some of the overlapping tiles functionality.
@ -921,41 +921,45 @@ void Crawler::LoadLevel(MapName map){
|
||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
||||
#pragma region TileGroupShenanigans
|
||||
auto SetupTileGroups=[&](std::function<bool(TilesheetData,int)>IsForeground,TileRenderData tile,std::set<vi2d>&foregroundTilesIncluded,std::vector<TileGroup>&groups){
|
||||
if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()){
|
||||
std::queue<vi2d>tileGroupChecks;
|
||||
TileGroup group;
|
||||
foregroundTilesIncluded.insert({x,y});
|
||||
group.InsertTile(tile);
|
||||
if(x>0)tileGroupChecks.push({x-1,y});
|
||||
if(x<WORLD_SIZE.x-1)tileGroupChecks.push({x+1,y});
|
||||
if(y>0)tileGroupChecks.push({x,y-1});
|
||||
if(y<WORLD_SIZE.y-1)tileGroupChecks.push({x,y+1});
|
||||
while(!tileGroupChecks.empty()){
|
||||
vi2d&pos=tileGroupChecks.front();
|
||||
tileGroupChecks.pop();
|
||||
int tileID=layer.tiles[pos.y][pos.x]-1;
|
||||
TilesheetData tileSheet=GetTileSheet(currentLevel,tileID);
|
||||
int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24;
|
||||
int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24;
|
||||
int tileSheetIndex=tileID-(tileSheet.firstgid-1);
|
||||
int tileSheetX=tileSheetIndex%tileSheetWidth;
|
||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),pos*24,vi2d{tileSheetX,tileSheetY}*24};
|
||||
if(IsForegroundTile(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find(pos)==foregroundTilesIncluded.end()){
|
||||
foregroundTilesIncluded.insert(pos);
|
||||
group.InsertTile(tile);
|
||||
if(pos.x>0)tileGroupChecks.push(pos+vi2d{-1,0});
|
||||
if(pos.x<WORLD_SIZE.x-1)tileGroupChecks.push(pos+vi2d{1,0});
|
||||
if(pos.y>0)tileGroupChecks.push(pos+vi2d{0,-1});
|
||||
if(pos.y<WORLD_SIZE.y-1)tileGroupChecks.push(pos+vi2d{0,1});
|
||||
int layerID=layer.tag.GetInteger("id");
|
||||
if(IsForeground(tileSheet,tileSheetIndex)){
|
||||
if(foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()){
|
||||
std::queue<vi2d>tileGroupChecks;
|
||||
TileGroup group;
|
||||
foregroundTilesIncluded.insert({x,y});
|
||||
group.originatingLayer=layerID;
|
||||
group.InsertTile(tile);
|
||||
if(x>0)tileGroupChecks.push({x-1,y});
|
||||
if(x<WORLD_SIZE.x-1)tileGroupChecks.push({x+1,y});
|
||||
if(y>0)tileGroupChecks.push({x,y-1});
|
||||
if(y<WORLD_SIZE.y-1)tileGroupChecks.push({x,y+1});
|
||||
while(!tileGroupChecks.empty()){
|
||||
vi2d&pos=tileGroupChecks.front();
|
||||
tileGroupChecks.pop();
|
||||
int tileID=layer.tiles[pos.y][pos.x]-1;
|
||||
TilesheetData tileSheet=GetTileSheet(currentLevel,tileID);
|
||||
int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24;
|
||||
int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24;
|
||||
int tileSheetIndex=tileID-(tileSheet.firstgid-1);
|
||||
int tileSheetX=tileSheetIndex%tileSheetWidth;
|
||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),pos*24,vi2d{tileSheetX,tileSheetY}*24};
|
||||
if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find(pos)==foregroundTilesIncluded.end()){
|
||||
foregroundTilesIncluded.insert(pos);
|
||||
group.InsertTile(tile);
|
||||
if(pos.x>0)tileGroupChecks.push(pos+vi2d{-1,0});
|
||||
if(pos.x<WORLD_SIZE.x-1)tileGroupChecks.push(pos+vi2d{1,0});
|
||||
if(pos.y>0)tileGroupChecks.push(pos+vi2d{0,-1});
|
||||
if(pos.y<WORLD_SIZE.y-1)tileGroupChecks.push(pos+vi2d{0,1});
|
||||
}
|
||||
}
|
||||
groups.push_back(group);
|
||||
}
|
||||
groups.push_back(group);
|
||||
}
|
||||
};
|
||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24};
|
||||
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsForegroundTile(sheet,tileID);},tile,foregroundTilesAdded,foregroundTileGroups);
|
||||
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsUpperForegroundTile(sheet,tileID);},tile,foregroundTilesAdded,foregroundTileGroups);
|
||||
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsUpperForegroundTile(sheet,tileID);},tile,upperForegroundTilesAdded,upperForegroundTileGroups);
|
||||
#pragma endregion
|
||||
}
|
||||
}
|
||||
|
@ -109,4 +109,12 @@ public:
|
||||
datafiledoubledata GetDoubleList(std::string key);
|
||||
static void OutputDebugInfo(const char*key,std::size_t len);
|
||||
void InitializeLevels();
|
||||
};
|
||||
|
||||
struct TileGroupData{
|
||||
vi2d tilePos;
|
||||
int layer;
|
||||
bool operator<(const TileGroupData&rhs)const{
|
||||
return layer<rhs.layer||(layer==rhs.layer&&tilePos<rhs.tilePos);
|
||||
}
|
||||
};
|
||||
};
|
@ -44,4 +44,5 @@ public:
|
||||
void InsertTile(TileRenderData tile);
|
||||
bool playerBehind=false;
|
||||
float fadeFactor=0.f;
|
||||
int originatingLayer=-1;
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 1069
|
||||
#define VERSION_BUILD 1079
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |