Pygame Rect Collision

后端 未结 2 502
太阳男子
太阳男子 2021-01-22 15:35

I am creating a game of Pong in Pygame with Python (obviously) and am new to Pygame so would like some help working the physics of when the ball touches the paddle, it will reve

2条回答
  •  再見小時候
    2021-01-22 16:02

    For the collision use the code below but change the variables

    If paddle1.colliderect(paddle2) or paddle2.colliderect(paddle1): That is the ball direction in the x-axis ballDirectionX*=-1

提交回复
热议问题