Let's say I have two rectangles overlapping each other like this...
And I want them to end up like this...
How would I calculate the position I need to add so that the rectangles move out of each other?
Note: I did find this question but it doesn't tell me how to actually move the rectangles.
Everyone's assuming I want to move the rectangle downwards, but I actually want the rectangle to move in the direction which would be the most logical. So that if the rectangle is completely to the right of the first rectangle and moves 1 pixel to the left, that it instead of moving downwards, it would move to the right.