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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user