Use AABB, it is super simple and there are plenty of things on here for that.
This only solves the e.collidesWith
, and is probably what tdegroot is already doing.
the amount of loops will explode exponentially
Technically it's only quadratic, but yes.
A BSP tree/kdtree/quadtree etc. can work, although a simple Bin/Cell
structure is much simpler and usually plenty effective.
It's also more performant than many trees when entities are often moving.
Note: The wiki page says each bin has a linked list, but just use an array list.