I've seen many tutorials for simple rectangle or circle-based collision detection with pygame.
But how can I do more complex collisions with arbitrary polygons?
Is the only option pixel-based collision detection?
|
I've seen many tutorials for simple rectangle or circle-based collision detection with pygame. But how can I do more complex collisions with arbitrary polygons? Is the only option pixel-based collision detection? |
|||
|
|
|
Short answer: yep. :P Long answer: rectangle collisions are built into Pygame. Circle collisions are simple math. Use Box2D for anything more complicated. |
|||
|
Have a look at pylygon.
It's rather lightweight compared to a full blown physics library, and collision detection is as simple as:
|
|||
|
|
|
I have developed a function for the collision of a circle and a rotated rectangle. Not very complex but this is everything I need for collision:
|
|||
|
|