def get_colour_key_hitmask(image, rect, key=None):
    """
    Returns a hit-mask using an image's colour_key.
    image -> pygame Surface,
    rect -> pygame Rect that fits image,
    key -> an over-ride colour, if not None will
        be used instead of the image's colour_key
    """
    if not key:
        colour_key = image.get_colorkey()
    else:
        colour_key = key
    mask = []
    for x in range(rect.width):
        mask.append([])
        for y in range(rect.height):
            mask[x].append(not image.get_at((x, y)) == colour_key)
    return mask