What's the fastest collision detection
13. Leden 2017 v 04:40
I want to build a simulator using Game Maker in which there are many (up to hundreds) of obj_Cell
, each has a radius of 10, (they don't have sprites, they just draw a circle with radius 10).
Each step, I want the cells to check around itself for obj_A
to see if any obj_A
is "touching" it, (has a distance less than 10 from the cell). However, since I have so many obj_Cell
and so many obj_A
, the most straight forward code (below) will have to be executed tens of thousands of times (number of obj_A * number of obj_Cell)
//In obj_Cell:
(with obj_A)
{
if distance_to_object(other)<=10
{
//do stuff
}
}
Is there any possible way to make this faster?