PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Bobble68
Party member
Posts: 160
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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
Dragon
Lovingsoul1337
Citizen
Posts: 53
Joined: Fri Feb 21, 2020 1:26 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post by Lovingsoul1337 »

sorry

ty for your patience.
Attachments
2DActionRogueLikeTest.zip
(5.03 KiB) Downloaded 32 times
User avatar
marclurr
Party member
Posts: 105
Joined: Fri Apr 22, 2022 9:25 am

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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.
Lovingsoul1337
Citizen
Posts: 53
Joined: Fri Feb 21, 2020 1:26 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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 !
RNavega
Party member
Posts: 251
Joined: Sun Aug 16, 2020 1:28 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post by RNavega »

In 'conf.lua', what happens if you comment out the vsync line so that the default (off) is used?
Lovingsoul1337
Citizen
Posts: 53
Joined: Fri Feb 21, 2020 1:26 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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.
Lovingsoul1337
Citizen
Posts: 53
Joined: Fri Feb 21, 2020 1:26 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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)
RNavega
Party member
Posts: 251
Joined: Sun Aug 16, 2020 1:28 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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.
Lovingsoul1337
Citizen
Posts: 53
Joined: Fri Feb 21, 2020 1:26 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post by Lovingsoul1337 »

yep the circle doesn't seem to stutter.

do you see any mistake in my player movementcode ?

https://pastebin.com/TdSZFQM5
RNavega
Party member
Posts: 251
Joined: Sun Aug 16, 2020 1:28 pm

Re: PlayerSprite stutter and eventually is artifacted if drawn on canvas else not

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Yolwoocle and 68 guests