Page 1 of 1

How to scale up the game correctly

Posted: Sun Sep 18, 2022 1:33 am
by soytak111
I've made my game whit a 420p resolution and i want to scale the game to work the same whit differents window size,how could i make it?What's all my choice?

Re: How to scale up the game correctly

Posted: Sun Sep 18, 2022 8:29 am
by darkfrei
soytak111 wrote: Sun Sep 18, 2022 1:33 am I've made my game whit a 420p resolution and i want to scale the game to work the same whit differents window size,how could i make it?What's all my choice?
Please explain the game visual art and how you want to upscale it.
The simple solution is to render graphics to canvas and scale it.
Another way is to use the love.graphics.scale.

Re: How to scale up the game correctly

Posted: Sun Sep 18, 2022 3:24 pm
by soytak111
darkfrei wrote: Sun Sep 18, 2022 8:29 am
soytak111 wrote: Sun Sep 18, 2022 1:33 am I've made my game whit a 420p resolution and I want to scale the game to work the same whit differents window size, how could I make it? What's all my choice?
Please explain the game's visual art and how you want to upscale it.
The simple solution is to render graphics to canvas and scale it.
Another way is to use the love.graphics.scale.
Well (at least for now) it's just drawing shape/text. I want the game to be the same whatever window size you have so that the game plays the same.

Re: How to scale up the game correctly

Posted: Sun Sep 18, 2022 7:14 pm
by darkfrei
soytak111 wrote: Sun Sep 18, 2022 3:24 pm
darkfrei wrote: Sun Sep 18, 2022 8:29 am
soytak111 wrote: Sun Sep 18, 2022 1:33 am I've made my game whit a 420p resolution and I want to scale the game to work the same whit differents window size, how could I make it? What's all my choice?
Please explain the game's visual art and how you want to upscale it.
The simple solution is to render graphics to canvas and scale it.
Another way is to use the love.graphics.scale.
Well (at least for now) it's just drawing shape/text. I want the game to be the same whatever window size you have so that the game plays the same.
Please try the multiresolution,
the main.lua for it:

Code: Select all

local MR = require ('multiresolution')
function love.load()
	-- window size:
	love.window.setMode(1920, 1080, {resizable = true, borderless = false})
	-- native resolution:
	MR.load(560, 420) -- target/native rendering resolution
	
	-- load code here
end

function love.update(dt)
	-- update code here
end


function love.draw()
	MR.draw()
	MR.drawTestBackground () -- example background
	-- draw code here
	
	love.graphics.setColor(1,1,1)
	love.graphics.print (MR.getMouseX()..' '..MR.getMouseY(), 0, 0)
end

function love.resize ()
	MR.resize()
end

function love.mousepressed( x, y, button, istouch, presses )
	x, y = MR.getMousePosition()
	-- code here
end

function love.mousemoved( x, y, dx, dy, istouch )
	x, y = MR.getMousePosition()
	-- code here
end

function love.mousereleased( x, y, button, istouch, presses )
	x, y = MR.getMousePosition()
	-- code here
end

function love.keypressed(key, scancode, isrepeat)
	MR.keypressed(key, scancode, isrepeat)
	
	if false then
	elseif key == "escape" then
		love.event.quit()
	end
end
But fonts must be changed with respect to MR.scale
multiresolution.lua
version 2022-09-18, license CC0 (no license)
(1.71 KiB) Downloaded 128 times

Re: How to scale up the game correctly

Posted: Sun Sep 18, 2022 9:38 pm
by GVovkiv
darkfrei wrote: Sun Sep 18, 2022 8:29 am But fonts must be changed with respect to MR.scale
multiresolution.lua
or check "resolution solution" https://github.com/Vovkiv/resolution_solution...
yeah, again shameless plug

Re: How to scale up the game correctly

Posted: Sun Sep 18, 2022 10:13 pm
by soytak111
darkfrei wrote: Sun Sep 18, 2022 7:14 pm
Please try the multiresolution,
the main.lua for it:

Code: Select all

local MR = require ('multiresolution')
function love.load()
	-- window size:
	love.window.setMode(1920, 1080, {resizable = true, borderless = false})
	-- native resolution:
	MR.load(560, 420) -- target/native rendering resolution
	
	-- load code here
end

function love.update(dt)
	-- update code here
end


function love.draw()
	MR.draw()
	MR.drawTestBackground () -- example background
	-- draw code here
	
	love.graphics.setColor(1,1,1)
	love.graphics.print (MR.getMouseX()..' '..MR.getMouseY(), 0, 0)
end

function love.resize ()
	MR.resize()
end

function love.mousepressed( x, y, button, istouch, presses )
	x, y = MR.getMousePosition()
	-- code here
end

function love.mousemoved( x, y, dx, dy, istouch )
	x, y = MR.getMousePosition()
	-- code here
end

function love.mousereleased( x, y, button, istouch, presses )
	x, y = MR.getMousePosition()
	-- code here
end

function love.keypressed(key, scancode, isrepeat)
	MR.keypressed(key, scancode, isrepeat)
	
	if false then
	elseif key == "escape" then
		love.event.quit()
	end
end
But fonts must be changed with respect to MR.scale
multiresolution.lua
I don't quite understand where to put code,can you explain it in more details please?

Re: How to scale up the game correctly

Posted: Wed Sep 21, 2022 4:31 pm
by milon
Anything you have in love.load() goes immediately after the "--load code here" part. Anything you have in love.update(dt) goes in the love.update function (as expected). Darkfrei was just giving you the framework to use the multiresolution library. It should work automatically across any display/resolution - at least that's my understanding. I've not used that particular library before.