123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|518|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Resolution woes

Wed, 24 Mar 2021, 15:21
Afr0

Resolution woes




So I'm trying to achieve resolution independence in Project Dollhouse, and I'm nearly there, but the login screen is giving me woes. It doesn't have UI scripts, which tells me they somehow must have hardcoded the position of everything in the code (ugh!)
What I've posted above obviously (as I came to realize) isn't resolution independent... but what is? How can I make this work for any resolution?
The LoginProgressDiag should be in the bottom right corner of the screen, and the LoginDiag should be in the middle of the screen.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Wed, 24 Mar 2021, 17:24
Jayenkai
I tend to create a VirtualResolution, then use maths to scale it to whatever resolution the screen/window is at.

TargetWidth=800; TargetHeight=600;
say..

And assume the window/screen is..
ScreenWidth=1920; ScreenHeight=1080;

A simple "stretch" would be
ScaleX=ScreenWidth/TargetWidth;
ScaleY=ScreenHeight/TargetHeight;

And then simply multiply all items (x and y co-ordinates as well as width and height, and also font sizes) by the ScaleX and Y values.

HOWEVER...
Be aware that doing that will cause everything to stretch if the Ratio of the screen is different. eg, I'm making a game for Widescreen, but the user has the window stretched into a Portrait/Tall view, then the stretch will be terrible..

What I tend to do is find a good average, and .. hope for the best!!!
ScaleAvg=(ScaleY+ScaleX)/2; oughta give you a vague average that you can use to scale both x and y values, and hopefully it should work.

You'll also need to check the things don't end up outside the boundary of the screen.. Check for If ((x*Scale)+(width*Scale))>ScreenWidth, then bump it back to a suitable point. Same for Y.

If you want to be really clever with it, using "areas" of the screen instead of co-ordinates, will generally make things a bit neater. Like GuiBoxA should be Top-Left, and GuiBoxB should be Bottom-Right.

Going one further, and probably not something you have time to mess around doing, but I've said a dozen times on this site that one of the BEST ways I taught myself to do that kind of stuff, was by creating a resolution-independent Testcard Screen. One that flows and resizes, but stays thematically the same.
Square grid, Circles on the edges, things like that.
It's a lot of maths to get it all working, but it teaches you an awful lot about resolutions, placements, scaling techniques and more.

.. But that's probably way too complicated. Start with the scaling, and see where that takes you.

-=-=-
''Load, Next List!''
Thu, 25 Mar 2021, 00:35
Pakz
I would say to turn it in percentages. The coordinates at 90% right would be th same at any resolution. But when I do things like this I have no idea what I am doing and modify the code until it works
Thu, 25 Mar 2021, 14:32
Afr0
I'm already using a virtual resolution, Jay!
Thanks for the tip, though!

So... if I check for , wouldn't that mean that I'd have to limit the number of resolutions I supported?

Because how would I know where to bump it back to?

Pakz, how would I turn the coordinates into percentages?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Thu, 25 Mar 2021, 14:41
Jayenkai
Maths, Afr0.
Maths!!

A=b+c
A-b=c
A-c=b

If you know that x+width>Screenwidth, then Screenwidth-width= The furthest x co-ordinate you should use.

-=-=-
''Load, Next List!''
Thu, 25 Mar 2021, 15:42
Afr0
Thanks!!