Big level objects collision system for 2d game
Posted
by
Aristarhys
on Game Development
See other posts from Game Development
or by Aristarhys
Published on 2012-07-09T18:08:52Z
Indexed on
2012/07/09
21:24 UTC
Read the original article
Hit count: 273
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
p1
,p2
are some sprites lets first just check with circle collision - because large distance betweenp1
,p2
this 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
p2
if it's in a column far fromp1
column, so we even don't do circle test. Butp3
is 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
p1
,p2
,p3
collision boxes, so we cut out things much top or belowp1
. 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:
© Game Development or respective owner