[Help] Techniques for scaling
Re: [Help] Techniques for scaling
Thanks! Rounding the physics body x and y then setting the x and y to the rounded values improved the snapping issue I was noticing as the player moves along the diagonal, as shown in the gif. However, I'm still noticing some snapping occurring as the player moves in relation to the background. Specifically, it seems that the fountain asset is jittering or snapping back and forth as the player moves horizontally. Do you have any suggestions for how I could address this problem and prevent the snapping effect?
Re: [Help] Techniques for scaling
Try change the player's max_speed field.
I tried change from 150 to 136 and the jittering appears to be gone.
I tried change from 150 to 136 and the jittering appears to be gone.
Re: [Help] Techniques for scaling
It seems like the solution of lowering the max speed to <= 135 resolves the issue for now. However, I'm curious about the underlying cause of this problem. Understanding why it's happening would help me develop a more generalizable solution for similar issues in the future. Can anyone provide an explanation for why this snapping phenomenon is occurring? It seems like it has to do with different objects not being drawn or positioned at integer pixel values?
Re: [Help] Techniques for scaling
I wanted to have a look at the issue, but RL is keeping me quite busy these days. Could you please indicate what kind of movement you want?
Specifically, my understanding is that you have a virtual resolution of 480x270 which is the underlying resolution, and you zoom it e.g. by 4 to get 1920x1080 in a 1920x1080 screen. Do you want the map/character to move pixel by pixel with the 1920x1080 resolution (i.e. in screen pixels) or do you want it to move with the 480x270 resolution (i.e. in increments of 4 screen pixels)?
Specifically, my understanding is that you have a virtual resolution of 480x270 which is the underlying resolution, and you zoom it e.g. by 4 to get 1920x1080 in a 1920x1080 screen. Do you want the map/character to move pixel by pixel with the 1920x1080 resolution (i.e. in screen pixels) or do you want it to move with the 480x270 resolution (i.e. in increments of 4 screen pixels)?
Re: [Help] Techniques for scaling
I'm wondering if there's anything unconventional about my current approach, and if there are more traditional methods for creating a top-down pixel game that I should explore.pgimeno wrote: ↑Thu May 09, 2024 12:36 pm I wanted to have a look at the issue, but RL is keeping me quite busy these days. Could you please indicate what kind of movement you want?
Specifically, my understanding is that you have a virtual resolution of 480x270 which is the underlying resolution, and you zoom it e.g. by 4 to get 1920x1080 in a 1920x1080 screen. Do you want the map/character to move pixel by pixel with the 1920x1080 resolution (i.e. in screen pixels) or do you want it to move with the 480x270 resolution (i.e. in increments of 4 screen pixels)?
Assuming my current approach is generally acceptable, I think I'm interested in the concept of pixel-perfect motion. From what I gather, this involves moving the character in increments of 1 screen pixel, irrespective of the underlying virtual resolution. For instance, in a 1920x1080 resolution, the character moves by 1 pixel, and in a 480x270 resolution, it also moves by 1 pixel. This means that each movement corresponds to 1/4 of a pixel in the virtual 480x270 resolution when viewed at 1920x1080. This method appears to promise smoother movement across different screen resolutions. However, I'm uncertain if there are any significant drawbacks associated with this approach.
Re: [Help] Techniques for scaling
OK, try this and see whether it helps:
Code: Select all
function PlayerCamera:update(dt)
local camX = Player.x
local camY = Player.y
local mapW = Map.width * Map.tilewidth
local mapH = Map.height * Map.tileheight
camX, camY = self:setBorders(camX, camY, mapW, mapH)
camX = math.floor(camX*self.scale + 0.5) / self.scale -- *** add this
camY = math.floor(camY*self.scale + 0.5) / self.scale -- *** add this
self:lockPosition(camX, camY)
self.x, self.y = self:position()
end
Re: [Help] Techniques for scaling
I tried this but it didn't seem to have much of an affect. Will you elaborate on the idea behind this?pgimeno wrote: ↑Thu May 09, 2024 6:31 pm OK, try this and see whether it helps:
Code: Select all
function PlayerCamera:update(dt) local camX = Player.x local camY = Player.y local mapW = Map.width * Map.tilewidth local mapH = Map.height * Map.tileheight camX, camY = self:setBorders(camX, camY, mapW, mapH) camX = math.floor(camX*self.scale + 0.5) / self.scale -- *** add this camY = math.floor(camY*self.scale + 0.5) / self.scale -- *** add this self:lockPosition(camX, camY) self.x, self.y = self:position() end
Re: [Help] Techniques for scaling
The idea is to round to screen pixels. It works for me, besides the obvious problems inherent to not using an integer scale, which cause image deformation.
Re: [Help] Techniques for scaling
When you say it "works for you" did you add this with no other rounding (Such as the player's physics body)
Re: [Help] Techniques for scaling
That's right. The character seems to jitter due to rounding problems and animation problems, but these are unrelated to the movement.
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests