Fix incorrect ordering of fade layers.
This commit is contained in:
parent
ce33e280ba
commit
50c9ddfad5
@ -884,10 +884,11 @@ void Crawler::LoadLevel(MapName map){
|
|||||||
}
|
}
|
||||||
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel});
|
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel});
|
||||||
}
|
}
|
||||||
|
//165,124
|
||||||
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded;
|
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded;
|
||||||
for(int x=0;x<WORLD_SIZE.x;x++){
|
for(int x=0;x<WORLD_SIZE.x;x++){
|
||||||
for(int y=0;y<WORLD_SIZE.y;y++){
|
for(int y=0;y<WORLD_SIZE.y;y++){
|
||||||
|
int layerID=0;
|
||||||
for(LayerTag&layer:MAP_DATA[currentLevel].LayerData){
|
for(LayerTag&layer:MAP_DATA[currentLevel].LayerData){
|
||||||
int tileID=layer.tiles[y][x]-1;
|
int tileID=layer.tiles[y][x]-1;
|
||||||
if(tileID!=-1){
|
if(tileID!=-1){
|
||||||
@ -899,20 +900,20 @@ void Crawler::LoadLevel(MapName map){
|
|||||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
||||||
#pragma region TileGroupShenanigans
|
#pragma region TileGroupShenanigans
|
||||||
auto SetupTileGroups=[&](std::function<bool(TilesheetData,int)>IsForeground,TileRenderData tile,std::set<vi2d>&foregroundTilesIncluded,std::vector<TileGroup>&groups){
|
auto SetupTileGroups=[&](std::function<bool(TilesheetData,int)>IsForeground,TileRenderData tile,std::set<vi2d>&foregroundTilesIncluded,std::vector<TileGroup>&groups){
|
||||||
int layerID=layer.tag.GetInteger("id");
|
if(foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()&&IsForeground(tileSheet,tileSheetIndex)){
|
||||||
if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()){
|
|
||||||
std::queue<vi2d>tileGroupChecks;
|
std::queue<vi2d>tileGroupChecks;
|
||||||
TileGroup group;
|
TileGroup group;
|
||||||
foregroundTilesIncluded.insert({x,y});
|
foregroundTilesIncluded.insert({x,y});
|
||||||
group.originatingLayer=layerID;
|
|
||||||
group.InsertTile(tile);
|
group.InsertTile(tile);
|
||||||
if(x>0)tileGroupChecks.push({x-1,y});
|
if(x>0&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{-1,0})==foregroundTilesIncluded.end())tileGroupChecks.push({x-1,y});
|
||||||
if(x<WORLD_SIZE.x-1)tileGroupChecks.push({x+1,y});
|
if(x<WORLD_SIZE.x-1&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{1,0})==foregroundTilesIncluded.end())tileGroupChecks.push({x+1,y});
|
||||||
if(y>0)tileGroupChecks.push({x,y-1});
|
if(y>0&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{0,-1})==foregroundTilesIncluded.end())tileGroupChecks.push({x,y-1});
|
||||||
if(y<WORLD_SIZE.y-1)tileGroupChecks.push({x,y+1});
|
if(y<WORLD_SIZE.y-1&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{0,1})==foregroundTilesIncluded.end())tileGroupChecks.push({x,y+1});
|
||||||
auto IterateThroughOtherLayers=[&](vi2d pos){
|
auto IterateThroughOtherLayers=[&](vi2d pos,bool loopAll=false){
|
||||||
|
int layer2ID=0;
|
||||||
|
bool hadForeground=false;
|
||||||
for(LayerTag&layer2:MAP_DATA[currentLevel].LayerData){
|
for(LayerTag&layer2:MAP_DATA[currentLevel].LayerData){
|
||||||
if(&layer==&layer2)continue;
|
if(!loopAll&&&layer==&layer2){layer2ID++;continue;};
|
||||||
int tileID=layer2.tiles[pos.y][pos.x]-1;
|
int tileID=layer2.tiles[pos.y][pos.x]-1;
|
||||||
TilesheetData tileSheet=GetTileSheet(currentLevel,tileID);
|
TilesheetData tileSheet=GetTileSheet(currentLevel,tileID);
|
||||||
int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24;
|
int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24;
|
||||||
@ -920,46 +921,62 @@ void Crawler::LoadLevel(MapName map){
|
|||||||
int tileSheetIndex=tileID-(tileSheet.firstgid-1);
|
int tileSheetIndex=tileID-(tileSheet.firstgid-1);
|
||||||
int tileSheetX=tileSheetIndex%tileSheetWidth;
|
int tileSheetX=tileSheetIndex%tileSheetWidth;
|
||||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
||||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{pos.x,pos.y}*24,vi2d{tileSheetX,tileSheetY}*24};
|
TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{pos.x,pos.y}*24,vi2d{tileSheetX,tileSheetY}*24,layer2ID};
|
||||||
if(IsForeground(tileSheet,tileSheetIndex)){
|
if(IsForeground(tileSheet,tileSheetIndex)){
|
||||||
foregroundTilesIncluded.insert({pos.x,pos.y});
|
foregroundTilesIncluded.insert({pos.x,pos.y});
|
||||||
group.InsertTile(tile);
|
group.InsertTile(tile);
|
||||||
|
hadForeground=true;
|
||||||
}
|
}
|
||||||
|
layer2ID++;
|
||||||
}
|
}
|
||||||
|
return hadForeground;
|
||||||
};
|
};
|
||||||
IterateThroughOtherLayers({x,y});
|
IterateThroughOtherLayers({x,y});
|
||||||
while(!tileGroupChecks.empty()){
|
while(!tileGroupChecks.empty()){
|
||||||
vi2d&pos=tileGroupChecks.front();
|
vi2d&pos=tileGroupChecks.front();
|
||||||
tileGroupChecks.pop();
|
if(IterateThroughOtherLayers(pos,true)){
|
||||||
int tileID=layer.tiles[pos.y][pos.x]-1;
|
foregroundTilesIncluded.insert({pos.x,pos.y}); //Regardless of if we found a foreground tile or not, we need to add this to not get stuck in an infinite loop.
|
||||||
TilesheetData tileSheet=GetTileSheet(currentLevel,tileID);
|
vi2d targetPos=pos+vi2d{-1,0};
|
||||||
int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24;
|
if(pos.x>0&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);}
|
||||||
int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24;
|
targetPos=pos+vi2d{1,0};
|
||||||
int tileSheetIndex=tileID-(tileSheet.firstgid-1);
|
if(pos.x<WORLD_SIZE.x-1&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);}
|
||||||
int tileSheetX=tileSheetIndex%tileSheetWidth;
|
targetPos=pos+vi2d{0,-1};
|
||||||
int tileSheetY=tileSheetIndex/tileSheetWidth;
|
if(pos.y>0&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);}
|
||||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),pos*24,vi2d{tileSheetX,tileSheetY}*24};
|
targetPos=pos+vi2d{0,1};
|
||||||
if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find(pos)==foregroundTilesIncluded.end()){
|
if(pos.y<WORLD_SIZE.y-1&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);}
|
||||||
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});
|
|
||||||
IterateThroughOtherLayers(pos);
|
|
||||||
}
|
}
|
||||||
|
tileGroupChecks.pop();
|
||||||
}
|
}
|
||||||
groups.push_back(group);
|
groups.push_back(group);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24};
|
TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24,layerID};
|
||||||
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsForegroundTile(sheet,tileID);},tile,foregroundTilesAdded,foregroundTileGroups);
|
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsForegroundTile(sheet,tileID);},tile,foregroundTilesAdded,foregroundTileGroups);
|
||||||
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsUpperForegroundTile(sheet,tileID);},tile,upperForegroundTilesAdded,upperForegroundTileGroups);
|
SetupTileGroups([&](TilesheetData sheet,int tileID){return IsUpperForegroundTile(sheet,tileID);},tile,upperForegroundTilesAdded,upperForegroundTileGroups);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
}
|
}
|
||||||
|
layerID++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(TileGroup&group:foregroundTileGroups){
|
||||||
|
for(TileRenderData&dat:group.GetTiles()){
|
||||||
|
if(dat.pos==vi2d{165,124}*24){
|
||||||
|
std::cout<<dat.layerID<<std::endl;
|
||||||
|
std::cout<<"=========="<<std::endl<<"After Sort:"<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::sort(group.GetTiles().begin(),group.GetTiles().end(),[](TileRenderData&t1,TileRenderData&t2){return t1.layerID<t2.layerID;});
|
||||||
|
for(TileRenderData&dat:group.GetTiles()){
|
||||||
|
if(dat.pos==vi2d{165,124}*24){
|
||||||
|
std::cout<<dat.layerID<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(TileGroup&group:upperForegroundTileGroups){
|
||||||
|
std::sort(group.GetTiles().begin(),group.GetTiles().end(),[](TileRenderData&t1,TileRenderData&t2){return t1.layerID<t2.layerID;});
|
||||||
|
}
|
||||||
|
|
||||||
int counter=0;
|
int counter=0;
|
||||||
bridgeLayerIndex=-1;
|
bridgeLayerIndex=-1;
|
||||||
|
@ -26,6 +26,7 @@ struct TileRenderData{
|
|||||||
Decal*tileset;
|
Decal*tileset;
|
||||||
vi2d pos;
|
vi2d pos;
|
||||||
vi2d tileSheetPos;
|
vi2d tileSheetPos;
|
||||||
|
int layerID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TileGroup{
|
struct TileGroup{
|
||||||
@ -44,5 +45,4 @@ public:
|
|||||||
void InsertTile(TileRenderData tile);
|
void InsertTile(TileRenderData tile);
|
||||||
bool playerBehind=false;
|
bool playerBehind=false;
|
||||||
float fadeFactor=0.f;
|
float fadeFactor=0.f;
|
||||||
int originatingLayer=-1;
|
|
||||||
};
|
};
|
@ -223,10 +223,6 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
|||||||
LayerTag l = {newTag};
|
LayerTag l = {newTag};
|
||||||
parsedMapInfo.LayerData.push_back(l);
|
parsedMapInfo.LayerData.push_back(l);
|
||||||
}else
|
}else
|
||||||
if (newTag.tag=="object"&&newTag.data["type"]=="UpperSpawnGroup") {
|
|
||||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
|
||||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")].upperLevel=true;
|
|
||||||
} else
|
|
||||||
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
|
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
|
||||||
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag};
|
||||||
} else
|
} else
|
||||||
@ -318,6 +314,23 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
|||||||
for(XMLTag&monster:accumulatedMonsterTags){
|
for(XMLTag&monster:accumulatedMonsterTags){
|
||||||
parsedMapInfo.SpawnerData[monster.GetInteger("spawnerLink")].monsters.push_back(monster);
|
parsedMapInfo.SpawnerData[monster.GetInteger("spawnerLink")].monsters.push_back(monster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(auto&spawnerData:parsedMapInfo.SpawnerData){
|
||||||
|
SpawnerTag&spawner=spawnerData.second;
|
||||||
|
for(auto&zoneData:parsedMapInfo.ZoneData){
|
||||||
|
if(zoneData.first=="UpperZone"){
|
||||||
|
std::vector<geom2d::rect<int>>&zones=zoneData.second;
|
||||||
|
for(geom2d::rect<int>&zone:zones){
|
||||||
|
if(geom2d::overlaps(zone,geom2d::rect<int>{{spawner.ObjectData.GetInteger("x"),spawner.ObjectData.GetInteger("y")},{spawner.ObjectData.GetInteger("width"),spawner.ObjectData.GetInteger("height")}})){
|
||||||
|
spawner.upperLevel=true;
|
||||||
|
goto continueSpawnerLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continueSpawnerLoop:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::cout<<"Parsed Map Data:\n"<<parsedMapInfo<<"\n";
|
std::cout<<"Parsed Map Data:\n"<<parsedMapInfo<<"\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 1147
|
#define VERSION_BUILD 1172
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -211,7 +211,7 @@
|
|||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<layer id="2" name="Layer 2" width="205" height="205">
|
<layer id="2" name="Layer 2" width="205" height="205" opacity="0.99">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
@ -63,7 +63,7 @@ MonsterStrategy
|
|||||||
# How far away the monster starts shooting from
|
# How far away the monster starts shooting from
|
||||||
Range = 800
|
Range = 800
|
||||||
# How often the enemy shoots.
|
# How often the enemy shoots.
|
||||||
ShootingSpeed = 0.6
|
ShootingSpeed = 2
|
||||||
BulletSpeed = 450
|
BulletSpeed = 450
|
||||||
BulletSize = 30
|
BulletSize = 30
|
||||||
BulletColor = 0, 255, 0, 255
|
BulletColor = 0, 255, 0, 255
|
||||||
|
Loading…
x
Reference in New Issue
Block a user