this is my first post, hope you can help me with this and sorry for my begginer english
Im working with c++ and SDL.
I want to make a 2D game that get the user`s resolution and set it for the game screen. But the images that use in the game will have wrong size and wrong position if the resolution is bigger or smaler than the resolution at which the game is done.
So, what can I do for keep the size and position of the images at the diferent resolutions?
You are using SDL's software rendering to draw (SDL_BlitSurface)?
In that case, just create a surface at the resolution the game is meant to be drawn at; blit to that, and stretch it to fit later. The alternative is to maintain a variable that is the ratio the player's resolution vs the expected (IE, if the player's resolution is 800x600, but the game is meant for 640x480, this variable will be 800/640 or 1.25), then multiply all rectangle's values by that variable (either pass it to each rendering function [ideal], store it in a global variable, or use a singleton), but this will likely require modifying a ton of code. Keep in mind that no matter what you do, in order to create useable mouse-input, you will need to convert real screen coordinates to expected screen coordinates (divide by the ratio mentioned above).