Hi
For my game’s map system I have a 2D array of [icode]Block[/icode] objects. I would like to resize/trim the array of null/empty rows and columns. Here is my current code, which doesn’t work
Block[][] clone = worldBlocks.clone();
int maxX = 0, maxY = 0;
for(Block[] row : clone){
if(row != null){
maxX = 0;
for(Block block : row){
if(block != null){
maxX++;
}
}
maxY++;
}
}
Block[][] refreshed = new Block[maxY][maxX];
for(int y = 0; y < maxY; y++){
for(int x = 0; x < maxX; x++){
refreshed[y][x] = clone[y][x];
}
}
worldBlocks = refreshed.clone();
This code should remove any null rows and columns, but it doesn’t Any thoughts or fixes would be appreciated
CopyableCougar4