int maxX = Math.min(width, widthInTiles + dx); int maxY = Math.min(height, heightInTiles + dy);
int maxX = Math.min(width, bounds.width + dx); int maxY = Math.min(height, bounds.height + dy);
    public void resize(int width, int height, int dx, int dy) {        Tile[][] newMap = new Tile[height][width];        int maxX = Math.min(width, widthInTiles + dx);        int maxY = Math.min(height, heightInTiles + dy);        for (int x = Math.max(0, dx); x < maxX; x++) {            for (int y = Math.max(0, dy); y < maxY; y++) {                newMap[y][x] = getTileAt(x - dx, y - dy);            }        }        map = newMap;        widthInTiles = width;        heightInTiles = height;    }