How to scale up the game correctly
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to scale up the game correctly
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
Re: How to scale up the game correctly
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
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
Re: How to scale up the game correctly
Please try the multiresolution,soytak111 wrote: ↑Sun Sep 18, 2022 3:24 pmWell (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.
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
Re: How to scale up the game correctly
or check "resolution solution" https://github.com/Vovkiv/resolution_solution...
yeah, again shameless plug
Re: How to scale up the game correctly
I don't quite understand where to put code,can you explain it in more details please?darkfrei wrote: ↑Sun Sep 18, 2022 7:14 pm
Please try the multiresolution,
the main.lua for it:But fonts must be changed with respect to MR.scaleCode: 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
multiresolution.lua
lua,contrary to other language,give you as much space as moon
Re: How to scale up the game correctly
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.
Who is online
Users browsing this forum: No registered users and 28 guests