有没有办法使用颜色在 PyGame 中的形状之间进行碰撞?

Is there a way to make collision between shapes in PyGame using colors?

有没有办法在 pygame 中当形状接触到特定颜色时发生碰撞。就像以某种方式控制某个形状(例如:弹力球、移动的形状等)时,是否有一种方法可以检测它是否触及了特定类型的颜色?

是的,你可以,这里是 senddex 的例子 link : https://pythonprogramming.net/detecting-collisions-intermediate-python-tutorial/

def is_touching(b1,b2):
    return np.linalg.norm(np.array([b1.x,b1.y])-np.array([b2.x,b2.y]))< (b1.size + b2.size)


def handle_collisions(blob_list):
    blues, reds, greens = blob_list
    for blue_id, blue_blob in blues.copy().items():
        for other_blobs in blues, reds, greens:
            for other_blob_id, other_blob in other_blobs.copy().items():
                if blue_blob == other_blob:
                    pass
                else:
                    if is_touching(blue_blob, other_blob):
                        blue_blob + other_blob
                        if other_blob.size <= 0:
                            del other_blobs[other_blob_id]
                        if blue_blob.size <= 0:
                            del blues[blue_id]
                            
    return blues, reds, greens