Manage multiple resolutions

Started by
3 comments, last by buumchakalaka 11 years, 7 months ago
Hi,
this is my first post, hope you can help me with this and sorry for my begginer english :P

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?

Thanks in advance :)
Advertisement
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).
Thanks you! Im going to try with this smile.png

EDIT: By the way, I found an article that have good information for this (if anyone have the same problem):
http://www.codeproject.com/Articles/293971/How-to-Correctly-Manage-Screen-Resolutions-in-Game
Also, don't stretch your GUI -- it makes things ugly.
Draw GUI after you stretch the game (and obviously, no need to convert coordinates if it's in the GUI).
Ok, I will keep in mind.

This topic is closed to new replies.

Advertisement