Members - Reputation: 131
Posted 08 October 2012 - 07:31 AM
Me and my girlfriend have been working on this fairly small game as a project for school for the last few months. This is the first major project we've taken on since we both started learning Java at the start of the year and as such we are constantly running into all kinds of issues that you encounter while mostly self-taught. So far we haven't gotten stuck in one place for too long (largely thanks to this great community), but now we've come to the quite significant issue of how to handle the oh-so-many varying screen resolutions which are found on computers these days. I've been looking 'round the web a fair bit and have so far found no real consensus on how this is supposed to be dealt with in a practical way.
With no other hope I finally got to making an account here on Gamedev and hope that someone would have an answer for us. For the project we decided that we wouldn't be using anything other than pure Java code, not using any pre-existing engines nor GUI builders such as the one in Netbeans. If any more info is needed for you to give a satisfying answer please let me know so.
Thanks in advance!
Members - Reputation: 3539
Posted 08 October 2012 - 08:59 AM
You can draw your game into another image or texture, and then render that to the center of the screen. If the screen is bigger, draw a background image first, then the game screen over it. Lots of games do this to handle different aspect ratios. You could also scale the image to the size of the screen, but that will likely cause ugly blurring, or other artifacts.
You could draw your objects without assuming any game resolution. Just anchor them tot he edges of the screen (if it's a gui),
Use normalized screen coordinates (0.0-1.0). This way, ScreenWidth * 0.5 is always the center of your screen. ScreenWidth * 0.0 is always the left edge. ScreenWidth * 1.0 is always the right edge.
You could just draw more.
Depends. Show us what your game looks like, and explain a bit more.
Edited by Daaark, 08 October 2012 - 09:03 AM.
Members - Reputation: 119
Posted 08 October 2012 - 01:37 PM
The game screen itself is planned to simply consist of a background image of the current room the player is located in (with floor, walls and some non-movable furniture) while anything else (the player, npcs, interactable objects) will be drawn onto this image later. I figure this is probably the standard approach to these kinds of things. I'm quite interested in the first suggestion you made (I assume that's also how you get the "black edges"), but isn't there a risk that the actual game screen will be very tiny on certain monitors in that case?