I solved it using pretty brute force
for each object as a
for each colliding object as c
if should_swallow(a, c)
swallow(a, c)
and do it several times in the loop because the objects grow when they swallow other objects, so the collision check must be done again (new overlaps may appear in the middle of the loop). Never press more than three cycles, but with the number of objects that I work with.
The should_swallow () function determines whether it is better to swallow or absorb objects, depending on size, position, and what happened in previous frames to prevent flickering.
source
share