I'm trying to develop a simple circular pong game in pygame. The game looks something like this.
At the moment I struggle with the direction of the ball after it hits the palette (that is theoretically just an arc).
So far I've done this but things don't seem that natural.
def getNewTraiectory(staAng, stpAng, ball, angle):
if(ball.speedX > 2.2 or ball.speedY > 2.2):
ball.speedX /= 2
ball.speedY /= 2
if (abs(angle-staAng) < abs(stpAng - angle )):
ball.speedX -=(stpAng - angle)/40
ball.speedY +=(stpAng - angle)/40
elif (abs(angle-staAng) > abs(stpAng - angle )):
ball.speedX += (angle - staAng)/40
ball.speedY -= (angle - staAng)/40
speed = random.uniform(0.7,1.96)
ball.speedX *= (-1)*(speed)
ball.speedY *= (-1)*(speed)
Where staAng is the starting angle of the pallete, stpAngle is the stopping angle of the pallete, ball is an object of the class Ball (that has a speed on axis X, a speed on axis Y and a position on both axes).
Theoretically, I just check the place where the ball hits on the sprite (close to the starting angle or closer to the stopping angle and based on that I try to give a somewhat opposite direction).
Can you help me to find a better method to give the direction of the ball bouncing the palletes?
