My code seems to work some of the time but the majority of the time the ball seems to just do what it wants. I assigned an angle to the ball class that changes up impact with the top and bottom of the screen as well as the player paddles, but sometimes the ball seems to ignore the logic and 'if' statements. I'm sure that I'm just missing something simple, but any help would be appreciated.
Note: "T_RECT" and "B_RECT" stand for the top and bottom of the screen respectively.
if (gameBall.rect.colliderect(T_RECT) or gameBall.rect.colliderect(B_RECT)) and bounce == 0:
gameBall.angle = 545 - gameBall.angle
bounce = 1
if (gameBall.rect.colliderect(redPlayer.rect) or gameBall.rect.colliderect(bluePlayer.rect)) and bounce == 0:
gameBall.angle = 365 - gameBall.angle
else: bounce = 0