Log In  


I've been working on building a simple and efficient platformer engine, and while it basically works, the character sprite can appear jittery depending on the character and camera movement, and I haven't figured out why. I've uploaded a prototype it you'd like to check it out. If anyone has some ideas or suggestions, I'd appreciate it, thanks.

Controls:

L\R-----------Move
Z-------------Run
X-------------Jump

Cart #munirumepe-0 | 2022-07-01 | Code ▽ | Embed ▽ | No License
3

3


1

Hi,
I've also encountered a problem with the sprites being jittery positioned in relation to scrolling.
The following fix seems to fix the problem.

-- if px-camx>=60 or (px-camx<=48 and camx>0) then
--  camx+=pdx
-- end

 camx=px-mid(px-camx,60,48)

I don't know if it's an internal API problem, but at least when dealing with decimal numbers,
I think it's easy to round values or cause jitters in the calculation process.


1

Here now the solution would be simple, @JadeLombax. Use a soft-camera scroller. That is adjust your scrolling to recognize when it is starting to jitter and move the camera smoother than the player actually is traveling until both match.


1

@shiftalow,

Thanks for the code snippet. It didn't fully fix the issue, but it did save me about 10 tokens.=)

I did some experimenting, and replacing use of the camera() function with just putting the camera offset value into the map() function seemed to do the trick. Not sure why, maybe the camera() function is doing some extra math that can introduce errors. Anyway, here's the fixed cart. There are still a couple little issues to work out in the collision, but no more jitter!

Cart #nopohituhi-0 | 2022-07-01 | Code ▽ | Embed ▽ | No License
1


This is interesting, I'll keep this in mind for my next project.



[Please log in to post a comment]