Ok, i apologize if you have trouble understanding me, my biggest problem in this world is putting my thoughts into words or on paper, so that others can understand
i’m working on a 2d engine purely using the java Graphics class
right now i have an 2d array of tiles(originally arraylist but fixed), i’m wanting to get a 20 x 20 chunk out of the entire arraylist, based on a location
HERES THE ISSUE i’ve ran into a problem where the location given to load the chunks will also determine how big the chunk loaded is, which should be a 20x20 tile chunk, i’m guessing it has to do with the function trying to get tiles that arent there(nulls) for example if i wanted to grab a chunk from location 1x1 then it would only grab 10 tiles into the positive direction, making it only a 10x10 chunk
heres my code
public Tile[][] getChunk(Locatable locatable){
Location location = locatable.getLocation();
Tile[][] chunk = new Tile[20][20];
for(Tile tile : tiles){//tiles being the tiles array
int tileX = tile.getLocation().getX(), tileY = tile.getLocation().getY();
if(tileX < location.getX() + 10 && tileX > location.getX() -10
&& tileY < location.getY() + 10 && tileY > location.getY() - 10){
chunk[tileX][tileY] = tile;
}
}
return chunk;
}