Detect connected tile groups and allow for fade out of the foreground layer when the player gets in range. These groups are initialized on level loading and self-expand.

This commit is contained in:
2023-06-22 23:28:16 -07:00
parent 5ffcf3126a
commit 60c8317b20
7 changed files with 96 additions and 7 deletions
+30
View File
@@ -0,0 +1,30 @@
#include "Map.h"
void TileGroup::InsertTile(TileRenderData tile){
if(tiles.size()==0){
range={tile.pos,{24,24}};
}
tiles.push_back(tile);
if(tile.pos.x<range.pos.x){
range.pos.x=tile.pos.x;
range.size.x+=range.pos.x-tile.pos.x;
}
if(tile.pos.x+24>range.pos.x+range.size.x){
range.size.x+=(tile.pos.x+24)-(range.pos.x+range.size.x);
}
if(tile.pos.y<range.pos.y){
range.pos.y=tile.pos.y;
range.size.y+=range.pos.y-tile.pos.y;
}
if(tile.pos.y+24>range.pos.y+range.size.y){
range.size.y+=(tile.pos.y+24)-(range.pos.y+range.size.y);
}
}
geom2d::rect<int>TileGroup::GetRange(){
return range;
}
std::vector<TileRenderData>&TileGroup::GetTiles(){
return tiles;
}