Log In  

Hi all!

I am working on a small pong clone:
https://www.lexaloffle.com/bbs/?tid=29815

I am unable to solve the paddle movement jerkiness.

It is working perfectly if I move 1px per time but, if I increase paddle speed, it becomes really...
Bad.

Any suggestions?

Thanks for your time and patience :)

P#44030 2017-09-09 14:23 ( Edited 2017-09-11 07:44)

:: solar

Hello. This may be relevant to you.

https://www.lexaloffle.com/bbs/?tid=29123

P#44040 2017-09-10 04:47 ( Edited 2017-09-10 08:47)
:: ltpitt

Hi solar!

Thanks for your kind help :)

I've read it but I am a simpleton and my mind is now blown:
https://media.giphy.com/media/26ufdipQqU2lhNA4g/giphy.gif

What should I do?

As far as I've understood I should change the speed of the pads but I am unsure of the formula I should apply...

P#44049 2017-09-10 13:02 ( Edited 2017-09-10 17:02)
:: solar

I'm thinking you can fix it by making sure you're moving by whole-pixel values per frame, and making sure that the paddles are positioned on screen with whole-pixel values as well. So basically you'd just be adding FLR() in a few places.

P#44081 2017-09-10 23:47 ( Edited 2017-09-11 03:47)

Hi, I've been struggling with a similar problem and I found that if you are moving an object less than 1 pixel you need to make sure that it's a power of two.

P#44082 2017-09-11 01:18 ( Edited 2017-09-11 05:18)
:: ltpitt

Hi guys!

While I was lurking like crazy on the forum I've found another priceless gem from ultrabrite and it works like a charm to solve my issue.

I cannot find the link again because I am a silly person but I've kept what he wrote.

What ultrabrite wrote:
--wrap around
if btn(0) then ship.x=(ship.x+127)%128 end
if btn(1) then ship.x=(ship.x+1)%128 end

-- more generally
ship.x=(ship.x+128+dx)%128

--walls
if btn(0) then ship.x=max(0,ship.x-1) end
if btn(1) then ship.x=min(ship.x+1,128) end

-- more generally
ship.x=mid(0,ship.x+dx,128)

P#44086 2017-09-11 03:31 ( Edited 2017-09-11 07:31)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-04-03 05:05 | 0.012s | 2097k | Q:22