Page 2 of 3
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Thu Jan 11, 2024 5:32 pm
by Bobble68
marclurr wrote: ↑Thu Jan 11, 2024 3:20 pm
Your link leads nowhere (for me at least). It would be easier for people to offer help if you attach your .love here directly.
Yeah discord message links will only work if you have access to that specific channel
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Thu Jan 11, 2024 7:55 pm
by Lovingsoul1337
sorry
ty for your patience.
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Fri Jan 12, 2024 9:09 am
by marclurr
There is a bit of 'jittering' but it's most likely the fluctuating delta time. As for graphical artefacts, I didn't notice any. That said, you can get a bit of persistence of vision with a large block of colour moving on a pure black background, which can look a bit like a ghost image. Is that what you mean? If so, the effect is usually reduced when you add some animation.
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Fri Jan 12, 2024 3:39 pm
by Lovingsoul1337
and you may know how get rid of this bit of jittering ?
https://www.youtube.com/watch?v=uvoMsw-4FC8
i think there are some at the edges and the sides top down left right.
what you mean with ghost image ?
and the strange is if i don't draw on canvas(you can close this easy out with 2 block comments in the love.draw method in the main.lua file)
it seems way better.
thanks in advance for all help so far !
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 12:35 am
by RNavega
In 'conf.lua', what happens if you comment out the vsync line so that the default (off) is used?
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 9:27 am
by Lovingsoul1337
doesn't seem to have any effect it seems to have always 120 fps on a 360 hz monitor. no matter vsync of commentet out or not.
but if i set it on false i get 60 fps.
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 9:31 am
by Lovingsoul1337
dunno can it have to do with the framebuffer ?(i dont know even what this is exactly but this came into my mind)
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 10:36 am
by RNavega
To help with debugging, I'd try drawing another element with a smooth animation, like some small shape going around a circular path. Drawing it like on the corner of the screen.
For example:
Code: Select all
local debugAngle = 0.0
function love.draw()
love.graphics.circle('fill', math.cos(debugAngle) * 100.0 + 200, math.sin(debugAngle) * 100.0 + 200, 25)
debugAngle = debugAngle + 0.1 -- Adjust this speed as necessary.
(...)
This way, when the player movement starts to stutter, I'd look at this other shape and see if it's also stuttering (so it's a display or framerate problem that affects the whole screen), vs it being some problem with the player movement code.
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 12:46 pm
by Lovingsoul1337
yep the circle doesn't seem to stutter.
do you see any mistake in my player movementcode ?
https://pastebin.com/TdSZFQM5
Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not
Posted: Sat Jan 13, 2024 8:31 pm
by RNavega
The problem is not in the movement code, although that is indeed written in a weird way: it's extremely difficult to control the player, as you're constantly accumulating speed on the xVelocity and yVelocity variables, making them huge. Like, you hold the key for 2 seconds and the xVelocity becomes as large as the entire map width.
xVelocity and yVelocity should have a top cap, a limit. That limit is usually reached instantly (whether the player is pressing the relevant keys or not), or the velocities can slowly work towards that limit in case you want to simulate acceleration, like in car racing games or realistic movement games like Prince of Persia, Another World etc.
But the actual stuttering problem comes from you drawing to an extremely small canvas, so there's not enough pixels to represent the soft position of the player, causing the impression of a stuttering. But it's lack of resolution. Edit: to clarify, when you upscale the canvas, what were pixels become larger squares on screen, and if the player is fast enough that they transition between pixels on consecutive frames, then when the canvas is upscaled, the player will step not between pixels but those actual squares, quite a big visual change.
Also, in love.draw() in main.lua, your "love.graphics.setBlendMode("alpha", "premultiplied")" line is causing text to render wrong.