Python 没有检测到我的一个物体的碰撞

Python doesn't detect a colliderect for one of my objects

我有这个代码

if ball.colliderect(border_up_rect):
    border_up_collide = True
elif ball.colliderect(border_down_rect):
    border_down_collide = True
elif ball.colliderect(goal_attack_rect):
    my_score += 1
elif ball.colliderect(goal_def_rect):
    ai_score += 1


if border_up_collide == True:
    if where_did_it_come_from == True:
        ball_x -= 7
        ball_y += 2
        pboard_shoot1 = False
        pboard_shoot2 = False
        pboard_shoot3 = False
    elif where_did_it_come_from == False:
        ball_x -= 3
        ball_y += 2
        ai_shoot1 = False
        ai_shoot2 = False
        ai_shoot3 = False
elif border_down_collide == True:
    if where_did_it_come_from == True:
        ball_x -= 7
        ball_y -= 2
        pboard_shoot1 = False
        pboard_shoot2 = False
        pboard_shoot3 = False
    elif where_did_it_come_from == False:
        ball_x -= 3
        ball_y -= 2
        ai_shoot1 = False
        ai_shoot2 = False
        ai_shoot3 = False
elif goal_attack_collide == True:
    if where_did_it_come_from == True:
        ball_x = 600
        ball_y = 220
        pboard_shoot1 = False
        pboard_shoot2 = False
        pboard_shoot3 = False
    elif where_did_it_come_from == False:
        ball_x = 600
        ball_y = 220
        ai_shoot1 = False
        ai_shoot2 = False
        ai_shoot3 = False

这里它适用于 border_up_rect 以及所有其他 collide.rect,但不适用于 border_down_rect。它只是让球通过它。

我该如何解决这个问题?

border_down_rect 不起作用的原因是因为 border_up_rect 仍然为真,并且在 border_up_rect 为真之前它不会切换 elif 语句。