public static void center(Unit unit)
    {
        int lX = unit.getX() - 4;
        int hX = unit.getX() + 4;
        int lY = unit.getY() - 4;
        int hY = unit.getY() + 4;
        
        int tX = xOff, tY = yOff;
        
        if(lX < xOff) {
            tX = lX < 0 ? 0 : lX;
        }
        if(hX > fieldWidth + xOff) {
            tX = hX > map.width ? map.width - fieldWidth : hX - fieldWidth;
        }
        
        if(lY < yOff) {
            tY = lY < 0 ? 0 : lY;
        }
        if(hY > fieldHeight + yOff) {
            tY = hY > map.height ? map.width - fieldHeight : hY - fieldHeight;
        }

        System.out.printf("Low x: %d\tHigh x: %d\tOffset x: %d\n", lX, hX, tX);
        System.out.printf("Low y: %d\tHigh y: %d\tOffset y: %d\n", lY, hY, tY);
        offset(tX, tY);
    }