Making a game for multiple resolutions

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Making a game for multiple resolutions

Post by Kibita »

Hello there!
I would like to know how people that use Löve makes your game to run in different screen resolutions. Any good library for this? I used Java Libgdx and it has the Viewports to make my drawables fit in any screen resolution (using virtual dimensions), but I don't know if Löve has this feature.

Thanks for support!
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Making a game for multiple resolutions

Post by T-Bone »

When working with 2D art, there's really no general solution to this problem. It depends on the type of game, and your art. For my old game, Hat Cat, it naturally supports zooming and panning, so just letting the windows become bigger worked just fine. For other games, hardcoding it for a handful of resolutions might be easier (and just scale or black bar the closest one when the display doesn't match). For mobile games, I'd target 480p and 720p. For computers/video games, I'd target 720p and 1080p.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Making a game for multiple resolutions

Post by bobbyjones »

For mobile I would imagine 720 and 1080 would be good too. I would assume most Android phones being sold now are at least 720 and high dpi.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Making a game for multiple resolutions

Post by Nixola »

A ridiculously high amount of phones isn't even 720p, so targeting 480p for mobile could still be needed.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Re: Making a game for multiple resolutions

Post by Kibita »

About resolution I got it, but how can I make them fit in all screen sizes by programming?
User avatar
Tchey
Prole
Posts: 25
Joined: Sun Jan 10, 2016 10:44 am
Contact:

Re: Making a game for multiple resolutions

Post by Tchey »

I don't have knowledge about it, but my guess would be to use everything %.screenSize instead of #.fixedValue. But maybe not.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Making a game for multiple resolutions

Post by zorg »

Kibita wrote:About resolution I got it, but how can I make them fit in all screen sizes by programming?
Depends on whether your game allows the visible area of the world being differently sized on different resolutions or not.
If it's allowed, then you just show a bigger chunk of the world, no extra scaling and stuff. For an example, refer to OpenTTD.
If it isn't for whatever reason, like it would give someone an unfair advantage or disadvantage, then select one resolution to use as the "internal" resolution, then if the screen is more or less, adjust it with love.graphics.scale. With code:

Code: Select all

love.graphics.scale(screenWidth/internalWidth, screenHeight/InternalHeight)
Do note that the above code will horribly distort the view if the aspect ratios don't match, so here's a fixed version that crops:

Code: Select all

local ratio = math.min(screenWidth/internalWidth, screenHeight/InternalHeight)
love.graphics.scale(ratio, ratio)
The alternate of that would be to use math.max, which would get you no black bars anywhere, but parts of the view will be "outside" the screen.
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.
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Re: Making a game for multiple resolutions

Post by Kibita »

Depends on whether your game allows the visible area of the world being differently sized on different resolutions or not.
If it's allowed, then you just show a bigger chunk of the world, no extra scaling and stuff. For an example, refer to OpenTTD.
If it isn't for whatever reason, like it would give someone an unfair advantage or disadvantage, then select one resolution to use as the "internal" resolution, then if the screen is more or less, adjust it with love.graphics.scale. With code:

Code: Select all

love.graphics.scale(screenWidth/internalWidth, screenHeight/InternalHeight)
Do note that the above code will horribly distort the view if the aspect ratios don't match, so here's a fixed version that crops:

Code: Select all

local ratio = math.min(screenWidth/internalWidth, screenHeight/InternalHeight)
love.graphics.scale(ratio, ratio)
The alternate of that would be to use math.max, which would get you no black bars anywhere, but parts of the view will be "outside" the screen.
Hmm that's nice! Would be great if next love2d version would have this feature.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Making a game for multiple resolutions

Post by zorg »

What feature? You can code this on your own in about 2-3 lines, don't be lazy! :3
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.
User avatar
Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

Re: Making a game for multiple resolutions

Post by Kibita »

zorg wrote:What feature? You can code this on your own in about 2-3 lines, don't be lazy! :3
Hahaha, sorry! I didn't want to mean that. I just tought that Love2d next time could have this: https://github.com/libgdx/libgdx/wiki/Viewports
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests