Background for different resolutions how to do it?

Hi.

I’m currently doing a menu-system in Java2D, and I need to accommodate several resolutions, including 4:3, 16:9 and 16:10 resolutions. So, which is the best way to go?

  • A background for each resolution? (many files; brute solution)
  • Scaled instances of a background created for the maximum resolution of that ratio? (spacesaver, simpler, but maybe ugly)
  • Try to compile each menu-background dynamically from several images (text, image of player or monster, whatever), making adjustments for each resolution
  • Make a menu for each ratio at a fixed resolution, then change to the selected resolution when the player enters a level

Ultraman,

Recently I had the same dilemma. I’m not an expert (yet) but this is what I came up with… matches closely to your second option.

I used a starting resolution of 1024x768, that’s the size of the background images and the default window size. I allow the user to change window size, but not ratio. So if the users drags their window to a new size or maximize the window, I only allow the height to change then set the width accordingly, this ensures the same ratio. Basically I did not want the user to warp the game. If the user has a real wide screen and they maximize, the window width would not make it across their whole screen. I did not have to do it this way and could have let them change the width independently of the height (and still might depending on what kind of feedback i get).

Will follow this thread closely to see what other, and yourself, have done.

thanks
jose

the probably easiest way is to just create layouts for each image ratio you want to support (5:4, 4:3, 16:10, 16:9, smartphones?)

The other way is to creat some simple “layout manager” by your self.
I did a little HUD for a game once where I did something so I could say.

component
{
left: 20px
bottom: 20px
height: 10%
width: height * 4
}

here are some other considerations you will take into account.

  1. download and storage size of your game. having multiple versions of your images and backgrounds will increase the overall size of your game.

  2. user expectations is just to drag or maximize their window. they no longer go to an options section to select their ratio.

Thanks. Those are some good pointers, all of you. You’ve helped me get a good idea about how I’m to approach this.
I had only considered this a full-screen project. Never thought about the possibility of windowed mode, actually.
I have some thinking to do.

Almost all bigger games require you do go through some menu to change resolution. It could be a loader/launcher or in game. They also have the most typical resolution/aspect ratio settings but not all. (no resizing the windows with mouse)

This makes it much, much easier to manager different resolutions. I would go with a few of the more mainstream resolutions with all the different aspect ratios. Do NOT try to make something that will let you resize the window to any resolution or aspect ratio.

As far as techniques to doing this goes, I got nothing. The layout manager seems good but DO NOT have multiple images at different resolutions that you load. This would be unnecessary bloat. Even in java2D scaling is very inexpensive.

Ultroman, here --> http://www.java-gaming.org/topics/2d-sprites-and-screen-resolution/23787/msg/239845/view.html#msg239845

Take a look at my last post, and to the other before written by Eli Delventhal.

Please! Please add windowed mode. I HATE fullscreen!

Well, I will in the scope that StumpyStrust described. A set variety of resolutions to choose from. Backgrounds in the maximum resolution for each ratio, then I’ll do that scaling-method The Cure has linked to. Seems very promising; thank you so much for that! A single call to scale all things drawn with the Graphics2D. That’s very clever :slight_smile: I’ll see how that’ll pan out.

Am I correct in saying that this method Eli posted will work for any resolution and any ratio, as long as you have a standard resolution set for each ratio? Considering I’ve had my poor artists design things for a screen-size of 1366x768, anyone on a lower resolution in this ratio will have everything scaled down, and everyone in a higher resolution of the same ratio will have everything scaled up, so they’ll all have the same size on-screen? Will this make it look muddy in higher resolutions? I’m gonna test it, but I have a good way to go at implementing this, so if anyone can stop me in my tracks, and say “No, you have to design everything to fit in the highest resolution you want to run, and only scale down”, I’d love to hear it.

Too much scaling can result in poor quality but I would suggest to use better filtering. Bilinear is it? That has very little performance drop and can greatly improve quality. I would not be too worried. If you want to support 1680-1050 and higher, you will probably start getting muddiness.

Are you guys saying that you actually scale every single image on the screen?

I currently use JavaFX. In JFX you only need to scale the root Parent node that contains all the other Nodes. JFX uses a tree structure to manage all the Nodes on the screen.

So far I have not noticed any problems with performance, which was a pleasant surprise.

    private static void windowResized() {
        double newHeight = stage.getHeight() - stageHeightPadding;
        if (Double.isNaN(newHeight) || stageHeightPadding == 0 || stageWidthPadding == 0) {
            return;
        }
        double newWidth = newHeight * RATIO;
        Scale scale = ScaleBuilder.create().pivotX(0).pivotY(0).x(newWidth / WIDTH).y(newHeight / HEIGHT).build();
        root.getTransforms().setAll(scale);
        stage.setWidth(newWidth + stageWidthPadding);
    }

scaling should never be a problem, one can always cache the results.

@jmart
That is what The Cure basically showed but with java2D.

The results are cache automatically in V-ram if the image is drawn enough and created properly.

We are talking about retaining quality when scaling. I don’t know much about that but if anyone else does, please enlighten us.

Yeah I just looked at it and it is very similar. Looking forward to checking out Java2d now.