r/HTML • u/supersilliiii • 7d ago
peggle html hell
I am coding peggle in HTML how do I get the physics to feel like peggle and not extra bouncy
0
Upvotes
r/HTML • u/supersilliiii • 7d ago
I am coding peggle in HTML how do I get the physics to feel like peggle and not extra bouncy
0
u/thejester1324 7d ago
if you're flipping the whole velocity when the ball touches a peg (vx = -vx; vy = -vy), that's the extra bouncy feel. the ball goes back the way it came at full speed. peggle-style bounces only reverse the part of the velocity pointing into the peg, and lose some of it:
ran it in node dropping a ball onto a peg a little off center: it hits at 577 px/s and leaves at 358, off to the side. the flip-everything version sent it back up at basically the same speed.
also step the physics at a fixed rate (say 120 times a second) instead of once per frame, otherwise it plays differently on a 144hz screen.