I read many variants today and get some knowledge in general, so here is a steps of mine thoughts in pictures (horrible paint.net ones).
We need to develop grid system, so we check only thing near, perform simple check to cut out deep check, and at - last deep check like per-pixel collision check.
Step 1 - Let
p2are some sprites lets first just check with circle collision - because large distance between
p2this fails and of course so we don't need test more deeply. But if we have not 2, but 20 objects, why we need to even circle test something so far outside of our view.
Step 2 - Add basic column system, now we don't bother with
p2if it's in a column far from
p1column, so we even don't do circle test. But
p3is in the same col, so let do circle test, which of course will fail.
Step 3 - Lets improve column system to the grid system with grid cell size just like
p3collision boxes, so we cut out things much top or below
p1. And this is all great until comes BIG OBJs which is some kind of platforms. They are much bigger then grid cell.
Circle test for will be successful, but deep check for whole big obj will fail
And that the part I can't get.
How do I store the grid position of big object? Like 4 grid coords for big object vertexes? And if one of them close to
p1 do circle check for centre of big object then a deep one if succeed? Am I do it wrong?
My possible solution: