pyglet icon indicating copy to clipboard operation
pyglet copied to clipboard

Feature Request: Collision Detection System

Open onlycs opened this issue 4 years ago • 2 comments

Would like a collision system for pyglet. Please allow it to detect collisions between sprites, other sprites, and pyglet.shape's.

Maybe:

list_of_items = [item2, item3, ...]
@window.event
def on_collide(item1, list_of_items): #if item1 collides with any item in the list
    print("It has collided")

onlycs avatar Nov 08 '21 19:11 onlycs

There are existing physics libraries out there such as pymunk. I think collision detection might be a bit out of scope for pyglet itself, however it is fairly simple to implement yourself. Here is a good article I would recommend using, it contains info on collision detection but you can take it further with resolution too.

LennyPhoenix avatar Nov 08 '21 19:11 LennyPhoenix

I would have to agree that it's a bit out of scope. Pymunk is a good suggestion for complex simulations, and should integrate smoothly without much trouble.

For simple AABB collision detection, it would be fairly easy to roll your own.

benmoran56 avatar Nov 09 '21 08:11 benmoran56