You're thinking about this the wrong way. You're thinking in terms of characters, background, etc. You need to be thinking in terms of a world, which can be viewed from any location. Or at least, a world that has a bounded area from which it can be viewed.
You should be able to position your camera in any arbitrary location you wish, within restrictions (like world boundaries). Your camera is what determines the offset for the "background".
For example, let's say your world starts at (0, 0). And it advanced to the right by 400 units, and up by 200 units. That's the boundary of your world. Now let's say that your camera can show a 20x15 rectangle of this world.
All entities have a position in the world. For example, maybe the player starts out at location (10, 5) (remember; positive X goes right, and positive Y goes up in this example). That's the player's world-space location.
When you render the player, you don't render them in world-space. You transform the player's position into screen-relative coordinates. To do that, you must define a camera, which represents a particular view of the world.
Let's say we want to center our camera (which is 20x15 in size) on the player's position, as much as possible within the boundaries of world space.
So the bottom-left position of the camera, given a player at (10, 5), would be the camera at (0, -2.5). That is half the camera width/height subtracted from the player's position. But since that is outside of the world, we clamp the Y value to 0. So the bottom-left of the camera is (0, 0).
Now, let's say the player moves to location (30, 20). Well, the bottom-left of the camera should be (20, 12.5). That's still within the world, so there's no need to clamp.
All of those camera positions we computed? Those are used to transform entities from world-relative coordinates to screen relative coordinates. This is done by simple subtraction.
If your camera is at (20, 12.5), and there's an entity somewhere that is at (30, 16), then the actual position of that entity on the screen is the entity's position minus the camera's position: (10, 3.5). This is the location you render him at (again, assuming bottom-left orientation. Most 2D renderers try to use top-left. The math is ultimately the same either way though).
So there needs to be a separation between "where the character actually is" and "where the character gets rendered on the screen".