Log In  

How do you achieve smooth character movement?

Normally, you'd take a speed value and multiply it by a delta time value so your character moves the same speed regardless of the clock speed. Pico-8 is frame limited to 30 FPS, but it still seems like my character jumps and hops by small amounts if I press and hold a button down.

Is it the right way to put: if btn(0, 0) x += 1.3 (or whatever) in the _update() and then spr(1, x, y) in the _draw()?

P#10880 2015-05-23 10:10 ( Edited 2015-05-25 03:33)

Yes, I think that should work.

Does, for example, idle doodle isle scroll smoothly for you? https://www.lexaloffle.com/bbs/?tid=1946&pid=10548

P#10892 2015-05-23 17:13 ( Edited 2015-05-23 21:13)

While you can change the coordinates as you please, keep in mind that pico-8 will always draw graphics on rounded coordinates, meaning that moving it in steps of 1.3 will appear as if it's moving 2px once per every ~3 frames and for 1px at other times.

P#10899 2015-05-24 05:56 ( Edited 2015-05-24 09:56)

so is the solution to always use full integers?

P#10901 2015-05-24 10:43 ( Edited 2015-05-24 14:43)

I wouldn't worry about always using full integers. You still get a a lot of varied movement speeds using floats, its just that the movement isn't as silky smooth as it could be.

If there was a deltaTime variable when calling _draw you could smooth it out nicer assuming there is still some variation when the _draw is called even when frame limited. I'll do some tests using Time() if it has enough precision.

I think the low resolution of the output is the main culprit.

P#10914 2015-05-24 23:33 ( Edited 2015-05-25 03:33)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 11:20:57 | 0.006s | Q:14