private void updateCamPos() {
        final int marginX = (int) (getWidth() * 0.25);
        final int marginTop = (int) (getHeight() * 0.2);
        final int marginBottom = (int) (getHeight() * 0.2);
        Point pos = hero.getPos();
        Dimension dim = hero.getSize();

        //      update x motion
        // If too far left
        if (pos.x - marginX < offX) {
            offX = pos.x - marginX;
        //if too far right
        } else if (pos.x + marginX > offX + getWidth() - dim.width) {
            offX = pos.x + marginX - getWidth() + dim.width;
        }
        //      update y motion
        //If too low
        if (pos.y - marginBottom < offY) {
            offY = pos.y - marginBottom;
        //If too high
        } else if (pos.y + marginTop > offY + getHeight() - dim.height) {
            offY = pos.y + marginTop - getHeight() + dim.height;
        }
    }