Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


How does resolution work?


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
3 replies to this topic

#1 Motoky   Members   -  Reputation: 183

Like
1Likes
Like

Posted 30 June 2014 - 06:22 AM

I've always wondered, when developing a game, there are obviously going to be a lot of different people with different specs and such. This is why you usually provide players with graphical settings so they can adjust it to suit there machines.

 

Now, I haven't made anything myself as of yet, but currently working on clones of games while adding to my own ideas and documents. How does resolution actually work? When you display a 2D game, you have all of the sprites in specific positions, when you increase the resolution of a game, those positions are going to change and aren't the sizes of the sprites going to change as well?? I have only messed with viewports in SFML before, so not 100% sure on how it all works, or even if that's the right thing to use.

 

Do you develop your games based around 1920 x 1080, or do you have to reset the positions and sizes of sprites, collision detection, etc. around different resolutions??



Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 5401

Like
9Likes
Like

Posted 30 June 2014 - 08:12 AM

The keywords are:

* multi-resolution images,

* resolution independent co-ordinate system,

* letter/pillow boxes.

 

Sprites can be available at different resolutions, and the set of sprites that best matches the given platform is chosen at the beginning. Also, don't think that 1:1 pixel mapping between the sprite and the screen is set in stone.

 

Regarding to sprite placement, collision detection and such: Pixels co-ordinates are bad for these purposes. Instead, use a virtual and resolution independent co-ordinate system. Map this to pixels lately during rendering.

 

Use window relative co-ordinates for the placement of GUI elements. E.g. the screen height is fine for normalization, so that the screen relative co-ordinates range from 0 to the aspect ratio horizontally and from 0 to 1 vertically. Further, allow for anchoring, so that GUI elements can be related e.g. to the left / center / right window border horizontally, and to the top / center / bottom border vertically. I personally do this by having 2 values per dimension, one that specifies the anchor position relative to the width or height, resp., and another that specifies an offset in relative co-ordinates (this time relative to the height for both dimensions), so that the anchor can be specified anywhere in the window.

 

The aspect ratio is the only real problem, if your playground is not allowed to be more visible for one player than for another due to competition reasons. In such a case you should work with pillar/letter boxes. Those don't need to be of ugly black but can be filled with some nice background.



#3 Buckeye   GDNet+   -  Reputation: 9041

Like
0Likes
Like

Posted 30 June 2014 - 08:26 AM


When you display a 2D game, you have all of the sprites in specific positions, when you increase the resolution of a game, those positions are going to change...

 

That depends on how you specify the positions. Rather than fixed pixel or window coordinates, you can specify the positions in screen-space coordinates to avoid having to recalculate everything. That is, (depending on your system) screen-space can run from (x=-1, y=+1) in the upper left corner, to (x=+1,y=-1) in the lower left corner. Those coordinates are independent of screen size and resolution. If you maintain a fixed aspect ratio, the layout of the screen will remain the same.

 

With that approach, you can use higher or lower resolution images for the sprites to be used with different screen resolutions. If you create each sprite image with the same aspect ratio (width/height ratio), you can load only the images with the resolution needed.


Edited by Buckeye, 30 June 2014 - 08:30 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


#4 Ravyne   GDNet+   -  Reputation: 10405

Like
7Likes
Like

Posted 30 June 2014 - 09:48 AM

The short version is that any game that supports multiple resolutions simply doesn't think in the screen resolution -- instead, all the game logic operates in its own coordinate system, and then after all the processing for a frame is complete, those coordinates are scaled ("projected") to the native resolution. This is similar to what you're already doing if your world or level is bigger than one screen, you just have to add scaling.

 

Today, with quite a wide variety of not just resolutions, but also aspect ratios (3/4, 2/3, 4/5, 16/9, 16/10, 21/9), you have to deal with that too -- this works the same way, combined with logic to implement appropriate safe-display regions and letter-boxing.


throw table_exception("(ノ ゜Д゜)ノ ︵ ┻━┻");





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