How to scale up the game correctly

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
soytak111
Prole
Posts: 25
Joined: Sat Sep 17, 2022 1:00 am

How to scale up the game correctly

Post 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?
lua,contrary to other language,give you as much space as moon :awesome:
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to scale up the game correctly

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
soytak111
Prole
Posts: 25
Joined: Sat Sep 17, 2022 1:00 am

Re: How to scale up the game correctly

Post 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.
lua,contrary to other language,give you as much space as moon :awesome:
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: How to scale up the game correctly

Post 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 124 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
GVovkiv
Party member
Posts: 668
Joined: Fri Jan 15, 2021 7:29 am

Re: How to scale up the game correctly

Post 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
soytak111
Prole
Posts: 25
Joined: Sat Sep 17, 2022 1:00 am

Re: How to scale up the game correctly

Post 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?
lua,contrary to other language,give you as much space as moon :awesome:
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: How to scale up the game correctly

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 49 guests