How to handle scaling to different resolutions?

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
KrimsonHorseman
Prole
Posts: 2
Joined: Wed Jan 02, 2019 7:44 am

How to handle scaling to different resolutions?

Post by KrimsonHorseman »

I'm making a pixel art game for let's say, 1280x720. I'm using the Push library to scale the virtual resolution to whatever the monitor's resolution is. When upscaled to something like 1920x1080 some of the sprites get slightly distorted or changed. I understand why that happens but what's the best solution for this problem?

One way I can think of is to not upscale it at all which would create a larger viewport showing more map area on the screen. Another way is to create assets for different resolutions which I honestly can't afford to do. Just wondering how you guys handle this for your games and also does anyone know how other games like stardew valley handle this? Do they upscale the resolution or just make the viewport bigger? Thanks.
CaptainLK
Prole
Posts: 3
Joined: Wed Jan 02, 2019 1:07 pm
Location: Germany

Re: How to handle scaling to different resolutions?

Post by CaptainLK »

I'm mostly developing for resolution of 800x600 pixels and later upscaling it like this:

Code: Select all

function love.load()
	original_width = 800
	original_height = 600
	window_width,window_height = love.graphics.getDimensions()
	window_scale_y = window_height/original_height
	window_scale_x = window_scale_y
	window_translate_x = (window_width - (window_scale_x*original_width))/2
	
	function love.draw()
		 love.graphics.translate(window_translate_x,0)
		 love.graphics.scale(window_scale_x,window_scale_y)
		 --Drawing--
		 love.graphics.setColor(0,0,0)
		 love.graphics.rectangle("fill",-window_translate_x,0,window_translate_x/2,original_height)
  		 love.graphics.rectangle("fill",original_width ,0,window_translate_x/2,original_height)
  	end
  end
	
Its not the best solution but works for most screen resolutions
A little example (Love2d 11.1):
Simple_shooter.love
(146.65 KiB) Downloaded 323 times
Only trying to help
User avatar
lydzje
Prole
Posts: 5
Joined: Sun Jul 22, 2018 2:36 am
Contact:

Re: How to handle scaling to different resolutions?

Post by lydzje »

I think there shouldn't be any issues scaling 1280x720 to 1920x1080, since you keep the same aspect ratio. In other cases, I would center the canvas in the window keeping the canvas ratio and leaving two black bars where necessary.

More details here: viewtopic.php?t=83406#p208548
NIL
Post Reply

Who is online

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