here's something that would help me and maybe others a lot if it could be done simply enough. how would you go about finding the second, and third, instance closest, like the instance_nearest function, but how would i find the one that are next? with variables maybe? indexes? arrays? i'm completely clueless on this subject...
Page 1 of 1
Instance_closest, And Second Closest find the instances after the nearest...
#2
Posted 12 May 2006 - 07:05 PM
There is a script for that. I'm now going to post one. There are many these kind of scripts so I'm not so sure is this like someone's... anyway, here's my fixed version, may look same than some other, but anyway...
NOTE: This required GM 6.x Registered...
// instance_nearest_nth(x,y,obj,nth) // If n = 1, then it returns the object himself var x1,y1,n,pq,a; x1 = argument0; y1 = argument1; n = argument3-1; pq = ds_priority_create(); with (argument2) ds_priority_add(local.pq,id,sqr(x-local.x1) +sqr(y-local.y1)); // This can be done with point_distance also repeat (n) ds_priority_delete_min(pq); a = ds_priority_find_min(pq); ds_priority_destroy(pq); return a;
NOTE: This required GM 6.x Registered...
This post has been edited by KaizuSellgren: 12 May 2006 - 07:07 PM
Share this topic:
Page 1 of 1

Help

MultiQuote








