I never used XNA but usually to solve this kind of issue you just need to abstract the position of your sprites from the actual resolution of the screen.
This means that you could store object position with absolute coordinates (eg. in range 0.0f - 1.0
) so that x = 0.0
is the leftmost pixel visible and 1.0
is the rightmost, same story for the y
coordinate.
You then calculate everything according to this coordinate space and you worry about transforming them just before the actual drawing. Of course for this approach you need to have different size that must keep the same ratio in a resolution-indipendent way.
For example, if you have 1080p then you choose to have 64x64 sprites, 1080/64 gives 16.875, so for a 720p resolution you will need 42.6pixels (like you chose: 42x42) and so on for other resolutions.
The transformation is then quite straightforward:
float xcord = ...
float ycord = ...
int xscreen = (int)(xcord*xresolution)
int yscreen = (int)(ycord*yresolution)
(I don't know if XNA already uses floats for coordinates)
In addition I actually don't know what kind of game you are making, but if your screen will show just a viewport of the whole world/game/whatever you can easily integrate the scrolling part together with this transformation because you can easily offset it to obtain screen coordinates:
float xcord = 15.4 /* something absolute to the world*/
int xscreen = (int)((xcord - xviewport_offset) * xresolution)
where xviewport_offset
should be the coordinate of the left side of the view port, of course the difference should be < 1.0
otherwise the sprite would be outside.