矩形和圆形碰撞-Pong Game

时间:2018-11-26 14:59:00

标签: python pygame

我的碰撞在矩形上方和下方都有效。 有时在侧面,但在大多数情况下,球的行为很奇怪: -在矩形的顶部和底部之间跳动

碰撞中出了什么问题或我可以改善什么?

if(ballX >= rectX1 and ballX <= rectX1 + rectWidth and ballY + ballRadius >= rectY1 and ballY - ballRadius <= rectY1 + rectHeight):
    ballMoveY = -ballMoveY


if(ballY >= rectY1 and ballY <= rectY1 + rectHeight and ballX + ballRadius >= rectX1  and ballX- ballRadius <= rectX1  + rectWidth):
    ballMoveX = -ballMoveX

Ball rect image

0 个答案:

没有答案