Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable collision detection between entities #8

Open
aaronamk opened this issue Oct 8, 2021 · 4 comments
Open

Enable collision detection between entities #8

aaronamk opened this issue Oct 8, 2021 · 4 comments
Assignees
Labels

Comments

@aaronamk
Copy link
Member

aaronamk commented Oct 8, 2021

Likely most will be circle collisions

@BlastWind
Copy link
Member

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

@BlastWind
Copy link
Member

Resources:

  1. Collision detection and response (starting page 173). This whole book is pretty good.

@BlastWind
Copy link
Member

@aaronamk what are the pros and cons of using circles, and of using rectangles?

@aaronamk
Copy link
Member Author

aaronamk commented Oct 16, 2021

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.

@aaronamk aaronamk mentioned this issue Nov 7, 2021
@aaronamk aaronamk changed the title Enable collision detection between actors Enable collision detection between entities Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants