1

Everything makes sense in my head. I don't understand why when I click on the button it does not work. I believe the problem is in these text lines

        mouse = pygame.mouse.get_pos()
        if mouse[0] >= rand_x <= player_size and mouse[1] >= rand_y <= player_size:
            sys.exit()"""

Python Code Image

SoapBox
  • 20,457
  • 3
  • 51
  • 87
Jordan
  • 11
  • 1

1 Answers1

1

In this statement:

mouse[0] >= rand_x <= player_size

what you are really saying is:

mouse[0]>= rand_X and rand_x <= player_size

So if rand_x is not lower or equal than player_size (50) it wont evaluate to True.

The documentation says:

Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y is found to be false).

Maybe what you meant is:

    rand_x <= mouse[0] <= rand_x+player_size