Search found 9 matches
- Fri Jan 10, 2025 4:26 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
Update: I simplify the code this way: -- file viewport.lua function self.update() if object then x = object.x - halfVirtualWidth y = object.y - halfVirtualHeight end end function self.render() if object then -- trembling if translating to not integer positions -- pass only integer values love.graphi...
- Mon Dec 30, 2024 8:14 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
Well but the x doesn't change since the movement of the player is on the y axis (up). If instead I'd move it left or right the x will change and the y will not. The getX/getY are getters: they simply return the value of the x/y field of the viewport object. The implementation of the MathHelper.round...
- Mon Dec 30, 2024 2:48 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
if showLocationSign then local ox, oy = love.graphics.inverseTransformPoint(0, 0) local vx, vy = MathHelper.round(viewport.getX()), MathHelper.round(viewport.getY()) print(('ox: %s, vx: %s, delta: %s, oy: %s, vy: %s, delta: %s'):format(ox, vx, ox - vx, oy, vy, oy - vy)) locationSignPanel.render(ox ...
- Mon Dec 30, 2024 1:03 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
But when I tried to round with:
as I answered back in the thread, the trembling still occurred, only a little bit decreased
Code: Select all
function MathHelper.round(n)
if n >= 0 then
return math.floor(n + 0.5)
else
return math.ceil(n - 0.5)
end
end
- Mon Dec 30, 2024 11:46 am
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
Just out of curiosity, I post the output of this piece of code: if showLocationSign then local ox, oy = love.graphics.inverseTransformPoint(0, 0) local vx, vy = viewport.getX(), viewport.getY() print(('ox: %s, vx: %s, delta: %s, oy: %s, vy: %s, delta %s'):format(ox, vx, ox - vx, oy, vy, oy - vy)) lo...
- Mon Dec 30, 2024 11:35 am
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
I agree with you, there's no clear explanation on why it works in this way. In my opinion the approach with the Viewport I implemented should be as good as the call to the "love.graphics.inverseTransformPoint" API. I think in some way there's a problem in the way the coords are interpolate...
- Sun Dec 29, 2024 7:04 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
At the end I resolved like this: if showLocationSign then local ox, oy = love.graphics.inverseTransformPoint(0, 0) locationSignPanel.render(ox + 2, oy + 2) locationSignText.render(ox + 4, oy + 6) end Is not what dusoft suggested but it's pretty close. This method given the "screen coords" ...
- Sun Dec 29, 2024 12:03 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Re: Object on the screen trembles if rendered with viewport coords
See these: https://love2d.org/wiki/Transform https://love2d.org/wiki/Transform:transformPoint https://love2d.org/wiki/Transform:inverseTransformPoint and maybe round instead of floor/ceil? http://lua-users.org/wiki/SimpleRound This is actually pretty cool, I am not so familiar with the use of Trans...
- Sat Dec 28, 2024 5:49 pm
- Forum: General
- Topic: Object on the screen trembles if rendered with viewport coords
- Replies: 19
- Views: 1304
Object on the screen trembles if rendered with viewport coords
Hi, I'm doing a RPG style game. I use a Viewport obejct for representing the area of the game actually rendered onto the the screen, but I use it also like a camera, because it is possible to lock the center of the viewport on a specific object (usually the player). I would like to develop the appea...