expandSector implementation

This commit is contained in:
Anuken 2018-09-21 08:49:35 -04:00
parent fc5a45e113
commit 569afb5535

View File

@ -75,6 +75,23 @@ public class Sectors{
* @param expandX spaces in X coordinate to expand, can be negative
* @param expandY spaces in Y coordinate to expand, can be negative*/
public boolean expandSector(Sector sector, int expandX, int expandY){
sector.width += expandX;
sector.height += expandY;
for(int x = sector.x; x < sector.x+sector.width; x++){
for(int y = sector.y; y < sector.y+sector.height; y++){
grid.put(x, y, null);
}
}
if(expandX < 0) sector.x += expandX;
if(expandY < 0) sector.y += expandY;
for(int x = sector.x; x < sector.x+sector.width; x++){
for(int y = sector.y; y < sector.y+sector.height; y++){
grid.put(x, y, sector);
}
}
return false;
}