I'm developing a game with Java using Slick2D and I want to make a game that could target all the recommended resolutions, as you can see in almost every game you could have an option of changing the resolution. I would like to know how game developers make their game assets once and use different screen resolutions and it still looks good.

My only guess is that when you're in game (playing-moving, jumping) the viewport of the camera is set to some size at the same aspect ratio of the player's monitor.

How do game developers do this? Not just in-game, even when just browsing the menu.

  • 1
    \$\begingroup\$ openGL will auto scale: the view port coordinates are from -1 to 1 \$\endgroup\$ – ratchet freak Dec 13 '13 at 19:15

On my android project, I achieved resolution independence by defining a VIRTUAL_SIZE(The "safe" area) and SCREEN_SIZE (The actual size of the screen). I further define SCALE to be the lesser of VIRTUAL_SIZE.X/SCREEN_SIZE.X and VIRTUAL_SIZE.Y/SCREEN)SIZE.Y. This ensures that I can scale up while still fitting the screen. Then any objects such as buttons or images are scaled up with SCALE and are drawn in a centered safe area defined by VIRTUAL_SIZE, while any "filler" such as background or particles are drawn into an unsafe area defined by SCREEN_SIZE.

Using this technique your playable area might not fill the screen, however you are given complete control of the game mechanics (game won't run differently on different devices) without limiting the visuals.

Of course you can always use different techniques. As an example, for some games you may need to enforce a variable height while always ensuring the width is the maximum.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.