I'm completely stumped on this prolly simple mathematic calculation.

To sum things up:
I got a viewpoint offset called Viewpoint.PosX and I've got an object onscreen with the variables Player.PosX, Player.PosY. Now the Y variables don't matter much in this case.

Both X offsets can go from 1 to 4000.

The limits are that the Viewpoint will not go further then 3200 as 800 is deducated to make sure the viewpoint doesn't go off screen.

What's a good way to center the viewpoint around the object?

Now I'm off to get some well deserved coffee -.-