[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/wsr/ - Worksafe Requests


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: pygame_camera.png (4 KB, 798x648)
4 KB
4 KB PNG
Can anybody help me figure out how to fix the jitter when the character moves diagonally?
It looks okay when I remove the normalisation of the movement vector on the diagonal, because then no floats are used. But I need that for consistent speed.
The camera introduces even more jitter, so I tried putting everything into math.floor or similar, but that didn't work.
Here's the code https://pastebin.com/ckFi85BG
>>
>>1502788
The problem is that you're sending the player coordinate to Camera's apply and update methods as a rect, and that uses only integer coordinates.
That introduces rounding errors, thus causing the jitter.
Send it as a tuple of floats instead, and turn it into a rect of rounded coordinates only when needed (at render).
https://pastebin.com/e92yRK4i
>>
>>1502860
Thank you so much!
>>
from what?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.