Page 1 of 1

How to handle scaling to different resolutions?

Posted: Wed Jan 02, 2019 7:57 am
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.

Re: How to handle scaling to different resolutions?

Posted: Wed Jan 02, 2019 1:33 pm
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 339 times

Re: How to handle scaling to different resolutions?

Posted: Fri Jan 04, 2019 2:24 am
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