push - a resolution-handling library
Re: push - a resolution-handling library
Ok. That makes sense. Thanks I’ll first remove the translation and see how the camera works. If I get any trouble I’ll start a new thread.
"kuzika" literally means "to burry"
Re: push - a resolution-handling library
I've been trying to figure out a major problem I've been having with this library -- when the game dimensions are a different aspect ratio than the screen dimensions, all canvases are drawn shifted relative to what they should be.
After spending a lot of time trying to track it down, I noticed that this only happens when the canvases are drawn in update (it works fine if the canvases are drawn in load).
Here's an example I made which draws a 1280x720 blue rectangle over a 1280x720 game (when the screen is 1500x720).
The conf.lua
The main.lua:
The canvas (blue) appears shifted right relative to where it should be by 110px (which is the same as how much the game is shifted relative to the screen, but this is an extra 110px on top of that).
I don't see the same issue if the code inside of love.update() gets run inside of love.load(). I'm not trying to draw a canvas on every iteration of the game, but occasionally things inside of love.update will trigger new canvases to be drawn.
After spending a lot of time trying to track it down, I noticed that this only happens when the canvases are drawn in update (it works fine if the canvases are drawn in load).
Here's an example I made which draws a 1280x720 blue rectangle over a 1280x720 game (when the screen is 1500x720).
The conf.lua
Code: Select all
function love.conf(t)
t.window.width = 1500
t.window.height = 720
end
Code: Select all
push = require("push")
local gameWidth, gameHeight = 1280,720
local windowWidth, windowHeight = love.window.getMode()
push:setupScreen(gameWidth,gameHeight,windowWidth,windowHeight,{fullscreen=false})
function love.update(dt)
thisCanvas = love.graphics.newCanvas(1280,720)
love.graphics.setCanvas(thisCanvas)
love.graphics.clear()
love.graphics.setColor(0,1,1,1)
love.graphics.rectangle('fill',0,0,1280,720)
love.graphics.setColor(1,1,1,1)
love.graphics.setCanvas()
end
function love.draw()
push:start()
love.graphics.rectangle('line',1,1,1280,720)
love.graphics.draw(thisCanvas,0,0)
push:finish()
end
I don't see the same issue if the code inside of love.update() gets run inside of love.load(). I'm not trying to draw a canvas on every iteration of the game, but occasionally things inside of love.update will trigger new canvases to be drawn.
Re: push - a resolution-handling library
push is not preserving the user transform. As a workaround, you can use love.graphics.origin() at the beginning of your love.update.
Note you don't need to create a canvas on every update. You can move the creation line to love.load, and leave the rest in love.update.
Note you don't need to create a canvas on every update. You can move the creation line to love.load, and leave the rest in love.update.
Re: push - a resolution-handling library
love.graphics.origin() worked perfectly! Thanks so much for the help, that issue has been bugging me for ages.
My canvas creation and drawing only gets called once (e.g. when a UI element such as the game map is created), but it happens in love.update() because it might get triggered from there (e.g. loading a game).
Push not preserving the user transform -- is this a bug? It's not the functionality I would have expected. Should I report an issue on the Github? I see this one which might be the same question.
My canvas creation and drawing only gets called once (e.g. when a UI element such as the game map is created), but it happens in love.update() because it might get triggered from there (e.g. loading a game).
Push not preserving the user transform -- is this a bug? It's not the functionality I would have expected. Should I report an issue on the Github? I see this one which might be the same question.
Re: push - a resolution-handling library
I would call it a bug, but Ulydev might have a different opinion. Best is to report it to the author to at least let him know so he can decide. The issue you linked doesn't seem related.
- SoupremeChickn
- Prole
- Posts: 1
- Joined: Wed Mar 15, 2023 2:51 am
Re: push - a resolution-handling library
Thanks for making this, this is really helpful.
Sometimes my brain just
doesn't
doesn't
Re: push - a resolution-handling library
The point was that love.update() gets called repeatedly and often (dt) and any resource heavy operations (canvas creation, fonts, sounds etc.) should be moved out, e.g. into love.load().
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: push - a resolution-handling library
Well, after 3 years finally someone answered!
Re: push - a resolution-handling library
It was already answered actually. And dusoft's answer misses the point: sometimes you have to load resources when the game is already running (e.g. loading a new level); love.load() won't help with that.
Re: push - a resolution-handling library
Indeed, but this is what scenes are for. You should still refrain from repeatedly creating/loading resource in love.update().
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Who is online
Users browsing this forum: No registered users and 0 guests