Help with Pong ball glitching

Alright so, I got a little pong game running and everything has been going pretty smoothly apart from this 1 major flaw/glitch - the ball will suddenly start going into the paddle and start giving the player a bunch of points.
If you can help me with this it would be much appreciated, If any code is needed just ask and ill oblige.


without code, I can only say: add a turn 180 degrees block and move like 2 steps.

with code, I can give a more accurate and personalized answer.

ok, I think I get the problem. try making it move by 5 steps or more. sorry for the late response, my wifi cut out for a minute.

Works! Thanks for the help :slight_smile:

no problem, but I realize now that it's not 180 degrees, but actually 90 degrees counter-clockwise. sorry about that.

I think you're thinking of the ball approaching the paddle from the southwest at a 45 degree angle. But in general a 90-degree turn won't do; think about the ball approaching the paddle from the left, horizontally. Instead of bouncing back, your ball will move upward.

Turning by 180 won't, in general, give the physically correct bounce angle, but at least it'll move back away from the paddle. So it's a nice simple okay solution.

The physically perfect solution has to use the ball's DIRECTION in computing the turn.

As I understand this going back 5 works in 'easy' mode where the most the ball has moved 5 steps. But if the ball moved 10 steps the ball may have penetrated the paddle by more than 5 steps.

Also while turning 180 isn't generally what real balls do.Itt guarantees you will back out the way you came in. But if you take 5 steps to back out at another angle you might still end up inside the paddle.

When I said 180 degrees, I meant 90. As bh has said, the rotaton is conditional. If the ball is facing 45 or -45 degrees, use 90 degrees counter clockwise. Is the ball is facing 135 or -135 degrees, use 90 degrees clockwise.

For the 10 steps thing, I have 2 solutions:

1: Do some crazy complicated recasting stuff to see if the ball will go through the paddle.

2: just remove the hard mode.

After turning the ball could repeatedly move forward 1 step until it is no longer touching the paddle.


One easy solution for the bounce angle is to multiply the current direction by -1. With respect the ball getting "stuck" inside the paddle, this can be addressed by giving the ball a "cool down" before it's allowed to bounce again (a wait 0.25 seconds is enough).

Multiplying by -1 is fine if paddles are vertical.I don't think it works if one wants horizontal paddles.

Why not just TURN 180 DEGREES?

To quote you

Turning by 180 won't, in general, give the physically correct bounce angle

Suppose your heading is 30 and you hit the paddle on the right you should now go -30 (or 330).

Yeah, but turning 180 will get you off the paddle in some okay direction regardless of the paddle angle.

Yes but multiplying by -1 (if the paddles are vertical) will also get you off the paddle and will be physically realistic.

Yeah that's my point! :~)

Point taken.

What is the goal here?

  1. Fix the immediate problem where the ball is stuck in the paddle but produce a clearly incorrect bounce?
  2. Fix the stuck ball AND produce a classic version of Pong (with vertical paddles)
  3. Produce a generic Pong where paddles can be any orientation (and shape?). Requires a deep dive into bouncing which may or may not be appropriate for this project.

Got me, it's not my project! :~P