Need help with aspect ratio and resolution

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Need help with aspect ratio and resolution

Post by xpali2 »

Okay so this is a problem that has puzzled me for the past 6 months. I am pretty much a beginner in coding a full game and am trying to make one for practice. I'm pretty much ready to give up on coding games all together if I can't fix this issue. I've looked for libraries that handle aspect ratio and resolution like TLfres but they are all outdated.

Anyway, my question is: What are the options for making a game work in different resolutions(Using pixel graphics that have been scaled up in logical increments such as 2x 4x 8x so they look the same)?. From what I understand it should be possible to simply change the window so it fits a smaller screen, where the graphics remain the same size. For example a base resolution in 16:9 1680 by 1050 and a different resolution that is in 4:3. Other players having a farther viewing range is not an issue.

If running this in resolutions with different aspect ratios is deemed impossible, then I also will have peace with the answer to the following question: How do I make it run on most resolutions of a 16:9 aspect ratio.

Any help at all either pointing to a library or a way I can achieve this myself would be greatly appreciated. Right now I am pretty much completely stuck.

Thanks,

Xpali2
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Need help with aspect ratio and resolution

Post by xpali2 »

This perfectly shows what I would like to achieve at about 0:16 https://www.youtube.com/watch?v=EcSyf5CoyaU
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Need help with aspect ratio and resolution

Post by zorg »

Do people not know how to use the search function? :3 I know, it's not the best...

Here you go: viewtopic.php?f=4&t=85638&p=222698#p222698

But for an extended answer, you have two options, if you want to keep your game pixel-perfect;
1. Choose one aspect ratio and use that with integral zoom levels (1x, 2x, 3x, 4x, 5x, etc.);
2. Calculate the nearest resolutions you'd be willing to show more (and less) of the world on the two axes using the aspect ratios you want to support, then do the same thing for all of those what you did in option 1.

Option two solves your issue, but it does present an issue itself, in that you must show a bit more and or less of the world, if you intend on keeping the visuals pixel-perfect.

To give you an example, OpenTTD works like this; it just shows more or less of the world, when resizing its window, and it also has an integral zoom function.



Also, just my 5 cents, but giving up because you can't write code like this seems to indicate to me that you should start with smaller projects instead; like pong or snake or tetris... this gets repeated ad nauseum everywhere, but for good reason; if you're not confident, you most likely can't pull off anything more complex.

If you're confident, then lack of skill is somewhat irrelevant since you have the drive to learn and reference stuff along the way... and that's actually somewhat expected, unless you prefer remembering every facet of löve, lua and whatever else you might need for a specific game (like "advanced" math, physics, color blending formulas, etc.).
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Need help with aspect ratio and resolution

Post by xpali2 »

zorg wrote: Wed Sep 12, 2018 12:35 am But for an extended answer, you have two options, if you want to keep your game pixel-perfect;
1. Choose one aspect ratio and use that with integral zoom levels (1x, 2x, 3x, 4x, 5x, etc.);
2. Calculate the nearest resolutions you'd be willing to show more (and less) of the world on the two axes using the aspect ratios you want to support, then do the same thing for all of those what you did in option 1.
.[/size]
Step one is clear to me. What exactly do you mean by the second point? If I would draw something to the top of the screen won't it still be different in the code? In one resolution you would have a y of say 1000 for the top of the screen while in a different resolution it falls off-screen.

Thanks for replying
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Need help with aspect ratio and resolution

Post by zorg »

The world coordinates for 0,0 should still be 0,0; regardless of the camera's aperture dimensions. Just adjust how much of the world you're showing. And use a camera lib if you're not yet.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Need help with aspect ratio and resolution

Post by xpali2 »

Ah yes I understand! I will be looking for a camera library then. Thanks
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 46 guests