Sign in to follow this  

The scale of a 2D world

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am confused on how I should relate sprites to the back buffer of a rendering API in a manner that is resolution and aspect ratio independent. In a 2D game, the entire visible world is obviously limited to the back buffer. When it's dimensions or aspect ratio changes, the world changes. My problem is that I am not sure how to respond with my sprites and 2D physics, etc. I noticed all titles do not address artifacts on display modes that do not match my monitor. Does this mean developers would make a 2D game and pick just ONE fixed buffer size to be considered the entire world and throw up their hands when it comes to stretching graphics to the front buffer? Or, do they implement all game logic once for each aspect ratio? For example, picture I'm switching from a 4:3 back buffer to a 16:9 one. My confusion comes from questions I ask myself like: "Ok, now where on the screen do things go that is an equivalent position?" As I have it now, my player is limited to the window client when in windowed mode, but can navigate the entire screen in fullscreen mode. If you were to be controlling the game, it looks like you didn't go fullscreen at all... Rather, you just gave the character more room to move.

Share this post


Link to post
Share on other sites
Well I guess you'd start by using graphics-independent world coordinates in the simulation. Then you'd pick a pair of world coordinates to center the viewport on. Then it should be a matter of simple arithmetic to transform world coordinates into view coordinates, regardless of aspect ratio.

Share this post


Link to post
Share on other sites
Right, just work in world coordinates and let your projection take care of getting stuff on-screen.

However, you also have to consider whether there is a gameplay consequence -- imagine an RPG that intended to hide some secret passage assuming a 4:3 screen, but on wide-screen the secret is clearly revealed. Also consider that a player might gain advantage over another with a different aspect ratio (or even just a different resolution, if you're tied to the screens resolution), so these are all things that must also be considered.

Share this post


Link to post
Share on other sites
So I am going to need the transformation pipeline for my projection transform can give me the AR correction I need, and I can work with objects using arbitrary units.

Thanks for that information!

Quote:
However, you also have to consider whether there is a gameplay consequence -- imagine an RPG that intended to hide some secret passage assuming a 4:3 screen, but on wide-screen the secret is clearly revealed. Also consider that a player might gain advantage over another with a different aspect ratio (or even just a different resolution, if you're tied to the screens resolution), so these are all things that must also be considered.


What would you do to ensure that no matter what resolution is used, the user still sees the same part of the world?

Share this post


Link to post
Share on other sites
Sorry I forgot to mention that.

The first thing is to determine if it matters and how -- if it doesn't matter, then let those high-res/widescreen players enjoy their fancy screens.

When it does matter, typically you would letterbox the screen, either top and bottom on 4:3 screens to make the visible area 16:9, or left and right on 16:9 screens to make the visible area 4:3. This approach is especially relevant in multiplayer games, where one player may gain advantage with a fuller field of vision.

In single player games, the above approach can also be used, but you may also simply define a "safe zone" that is not necessarily the same size or aspect ratio as the physical screen, and you simply design your game so that all the critical information is presented within that zone (and conversely, that you hide all your secrets far enough away that they'll never reveal themselves in the "bonus" viewport area between the safe zone and the edge of the physical screen, whatever its resolution and aspect ratio is.

Another important thing to consider, is that perhaps very high resolutions get higher-fedelity graphics, rather than a fuller field of view. In this case, as long as you design your graphics at twice the "typical" resolution, you should be able to satisfy even the highest-resolution users.

Finally, consider allowing the game run in a window -- its less immersive for sure, but some users will appreciate being able to see their IRC channel crawl, or keep an eye on their IMs [grin]

Share this post


Link to post
Share on other sites

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this