c++ - Better way to check game objects collisions -


guys! have problems processing collision of game objects (with other sizes). algorithm is:

for (array<gameobject*>::iterator = objects.begin(); != objects.end(); it++) {    rect objrect = (*it)->getboundingbox();    (array<gameobject*>::iterator it2 = object.begin(); it2 != object.end(); it2++)    {       rect objrect2 = (*it2)->getboundingbox();       intersectrectangles(objrect, objrect2);    } } 

yes, works fine. works slow. have idea (check nearby objects object), means more , more iterations. maybe better way exist?

you can divide game world big zone, , check collssion of game ojcects in 1 zone just. basic method.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -