since ur update_postition() is called from the while(1) loop, it will keep incrementing the position when the distance is lesser than ai1_distance.

if u want the distance to be alwys updated and the position to be updated only once. then put a condition there

while(1)
{
distance = vec_dist(endpoint.x, my.x);
if(some condition)
{
ai1_distance = vec_dist(endpoint.x, ai1.x);
ai2_distance = vec_dist(endpoint.x, ai2.x);
update_position();
}
wait(1);
}


That (some condition) u can set. when do u want to update the postion only once.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook