I'm making a pipe connection game in Pygame where you rotate a set of given pipe pieces to connect the start to the end, and am having trouble making a way for the game to actually be completed. I need to find if any path of white pixels (from the pipe piece sprites) connects any red pixel to any blue pixel (the colours of the start and end pieces). How could I go about doing this? The background colour is black, if that helps.
I would make a scraper-like tool:
1 From each red pixel check for connecting white/blue pixels, put these in a list
2 From each white pixel in the list, check if a blue pixel can be reached, if so , return True
3 add any white pixels that connect to white pixels already in the list (but don't add any that already are in the list)
4 if no new white pixels where added and no blue pixels where found, return False. else, go back to step 2
How can I find if there is a white path connecting pixels of two different colours in Python / Pygame?