looking for a light weight way to find objects within a radius.
so far the answer that is obvious to me is go through each object, comparing its x and y position, with the center of the radius.
example:
Turret - looking for targets in radius. TargetArray - array of possible targets.
WithinRangeArray - array we push applicable targets to
Distance^2 = (TargetArray[n].x - Turret.x)^2 + (TargetArray[n].y - Turret.y)^2
if( Distance^2 < maxRadius^2 ){ WithinRangeArray.push(TargetArray[n]) }
avoiding the square root should save me some processing power. But i have the feeling there may be other algorithms/theories/methods that may be better (more light weight).
Language: Flash AS3
Ideal length of TargetArray: fewer than 500 targets at a time.