1

I am making a game in python with pygame, and I am wondering if there is any class (with collisions) in pygame that supports non-AABB polygons. I know there is the pygame.draw.polygon function, but that takes a list of points instead of a rect like pygame.draw.rect.

Is there any way to do this in pygame?

If not, are there any pygame-compatible libraries that could do this?

If there are no libraries, how could I implement it?

  • Thanks, that seems great! Could you post that as an answer so I can accept it? –  Aug 09 '21 at 21:21

1 Answers1

1

The pygame.draw module does not generate objects. It just draws something on a Surface. You cannot use this for collision detection. I think you're confusing pygame.Rect and the pygame.draw module.
The collision detection in pygame is based on rectangles or circles. See How do I detect collision in pygame?.
Another option is to use pygame.mask.Mask objects, which you can use to detect overlapping shapes and sprites. See Pygame mask collision

Rabbid76
  • 202,892
  • 27
  • 131
  • 174