Open aaronamk opened 3 years ago
Insight: On every frame, we loop through dynamic actors (characters, traps, teleport door, etc) and detect for collision.
Here's my quick thought on the structure: Each actor has a onCollide(&Actor otherActor)
method that runs conditional code based on what the type of the other actor is. There is a contact listener that calls the onCollide
method for the actors.
See how Aaron implemented the idea using a sexy listener object in Parryt: https://github.com/GDC-WM/Parryt/blob/main/src/contact_listener.cpp
Resources: 1) Collision detection and response (starting page 173). This whole book is pretty good.
@aaronamk what are the pros and cons of using circles, and of using rectangles?
Here's a very relevant file from the homegrown physics branch of Parryt. For whoever completes this issue, please refer to this for how to implement the actual math of the collisions.
pros and cons of using circles, and of using rectangles
There's no real pros or cons. Both systems are very simple to implement and we will likely have to use both. For each entity, just use the shape that most closely approximates the shape of that entity. Walls will be rectangles, characters will likely be circles (for a top-down view game), etc.
Likely most will be circle collisions