Original Post
Hey there. I'm trying to implement some basic physics/collisions in my game. I have the formulas I need and I actually have working test collisions with objects(just looping through and checking if they collide). Right now I just have a player(circle physics body), a single enemy(circle physics body), and a static axis aligned rectangle(rectangle physics body obviously). However, I want to add a lot more enemies but I'm not quite sure of the "best" way to do it.
Say there are 100 circular enemies and I want them to all check for collisions with each other. So I would go about this by looping for each of these enemies and checking if they collide with every other enemy on the list. I can see that this isn't really all that efficient so I'm wondering how I could make it better. I only want them to check the ones around them. So I guess I should have a simple distance check to see if they are in the radius of each other, and then do the more complicated checks. What can I do on top of this or instead of this?
Thanks.
EDIT: NOTE: I'm using C++
EDIT2: With some googlin' I have come across the term "broad-phase algorithms" and I think this is what I'm looking for. I've heard the term, just never knew what it was about. Any good sources on this would be really helpful(I'll continue looking).
EDIT3: Or quadtrees? This seems like what I'm gonna roll with. I'll try it.
Say there are 100 circular enemies and I want them to all check for collisions with each other. So I would go about this by looping for each of these enemies and checking if they collide with every other enemy on the list. I can see that this isn't really all that efficient so I'm wondering how I could make it better. I only want them to check the ones around them. So I guess I should have a simple distance check to see if they are in the radius of each other, and then do the more complicated checks. What can I do on top of this or instead of this?
Thanks.
EDIT: NOTE: I'm using C++
EDIT2: With some googlin' I have come across the term "broad-phase algorithms" and I think this is what I'm looking for. I've heard the term, just never knew what it was about. Any good sources on this would be really helpful(I'll continue looking).
EDIT3: Or quadtrees? This seems like what I'm gonna roll with. I'll try it.
