Search code examples
pythonpygamepixelrgbtetris

Get the value of an individual pixel


I'm making Tetris and im trying to make a line clear function. I have a way to do this that is a bit complicated and im looking to simplify.

My idea is to check some pixel RGB values and see if they're not black (the color of the background). Is there a quick way to get the RGB value of a pixel on the screen?


Solution

  • pygame.PixelArray should do the trick. You can use it on the screen surface.

    But personally, I wouldn't recommend that you use the pixels as a reference. Handling everything logically is a lot better.