Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Background for different resolutions how to do it?  (Read 1490 times)
0 Members and 1 Guest are viewing this topic.
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Posted 2012-08-03 12:40:28 »

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

- Jonas
Offline jmart

Junior Member


Medals: 1



« Reply #1 - Posted 2012-08-04 08:04:14 »

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

 
Offline Danny02
« Reply #2 - Posted 2012-08-04 08:40:24 »

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
}
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jmart

Junior Member


Medals: 1



« Reply #3 - Posted 2012-08-04 14:11:23 »

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.
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #4 - Posted 2012-08-04 22:30:53 »

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.

- Jonas
Offline StumpyStrust
« Reply #5 - Posted 2012-08-04 22:50:00 »

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.

Offline The Cure

Senior Newbie





« Reply #6 - Posted 2012-08-05 02:58:38 »

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.

"A candle loses nothing by lighting another candle" - Erin Majors
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #7 - Posted 2012-08-05 13:13:55 »

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.
Please! Please add windowed mode. I HATE fullscreen!

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #8 - Posted 2012-08-05 13:55:21 »

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 Smiley I'll see how that'll pan out.

- Jonas
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #9 - Posted 2012-08-05 20:15:38 »

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.

- Jonas
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StumpyStrust
« Reply #10 - Posted 2012-08-05 20:26:02 »

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.

Offline jmart

Junior Member


Medals: 1



« Reply #11 - Posted 2012-08-05 20:48:52 »

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.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
    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);
    }
Offline Danny02
« Reply #12 - Posted 2012-08-05 22:38:39 »

scaling should never be a problem, one can always cache the results.
Offline StumpyStrust
« Reply #13 - Posted 2012-08-06 00:19:20 »

@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.

Offline jmart

Junior Member


Medals: 1



« Reply #14 - Posted 2012-08-06 02:58:00 »

Yeah I just looked at it and it is very similar.  Looking forward to checking out Java2d now.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (15 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (16 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!