Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Manage multiple resolutions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 buumchakalaka   Members   -  Reputation: 268

Like
0Likes
Like

Posted 24 August 2012 - 04:46 AM

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 :)

Sponsor:

#2 nfries88   Members   -  Reputation: 259

Like
1Likes
Like

Posted 24 August 2012 - 06:31 AM

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).
Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.

#3 buumchakalaka   Members   -  Reputation: 268

Like
0Likes
Like

Posted 24 August 2012 - 07:06 AM

Thanks you! Im going to try with this Posted Image

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

Edited by buumchakalaka, 24 August 2012 - 07:11 AM.


#4 nfries88   Members   -  Reputation: 259

Like
1Likes
Like

Posted 24 August 2012 - 07:49 AM

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).
Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.

#5 buumchakalaka   Members   -  Reputation: 268

Like
0Likes
Like

Posted 24 August 2012 - 08:28 AM

Ok, I will keep in mind.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS