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
Post a Comment