1

The following code runs code if these conditions are met:

  • User clicks on a surface called box
  • the box must be moving in at least one direction
if ((boxLeft < pygame.mouse.get_pos()[0] < boxLeft + BOX_SIZE) and (boxTop < pygame.mouse.get_pos()[1] < boxTop + BOX_SIZE)) and ((dx != 0) and (dy != 0)):

This does not happen. Instead, the code only runs if the box is moving in both directions (if both do not dx and dy == 0)

Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

1

I think you meant to do ((dx != 0) or (dy != 0)) so it can detect when it's just moving in one direction.

Seth
  • 2,214
  • 1
  • 7
  • 21