0
\$\begingroup\$

Basically, I created a grid with this:

for x in range(0, WINDOW_WIDTH, blockSize):
        for y in range(0, WINDOW_HEIGHT, blockSize):
            rect = pygame.Rect(x, y, blockSize, blockSize)
            pygame.draw.rect(SCREEN, WHITE, rect, 1)

and I need to see if the player clicked on one of the grids. How do I do this? All help is appreciated!

\$\endgroup\$
2
  • \$\begingroup\$ This seems to already be answered on StackOverflow - found by searching "pygame click rect". Did you have any difficulty implementing the solutions you found when doing this basic research before posting a new question? \$\endgroup\$
    – DMGregory
    May 31, 2022 at 13:46
  • \$\begingroup\$ I started answering this twice before realizing that the question needs clarification. Do you want to know whether a square is being clicked, which square is being clicked, whether an intersection is being clicked, or which intersection is being clicked? \$\endgroup\$
    – Ian Moote
    Jun 2, 2022 at 19:43

0

You must log in to answer this question.

Browse other questions tagged .