I don't know how to do this. Please help me.
highestBlueCloneindex = cloneindex;
Actor *getclone2(char* cname, int cindex)
{
char buffer[30];
sprintf(buffer,"%s.%d", cname, cindex);
return(getclone(buffer));
}
int i;
Actor* closest = NULL;
float closest_dist = 0;
for(i=blueClone.cloneindex; i<=highestBlueCloneindex; i++)
{
Actor* i_clone = getclone2("blueClone", i);
if(i_clone->cloneindex!=-1) // the clone's cloneindex is -1 when the clone does not exist, this checks only if the clone exists
{
float i_dist = distance(x, y, i_clone->x, i_clone->y);
if(closest == NULL || closest_dist > i_dist) // either there is no closest assigned yet, or the current one is closer
{
closest_dist = i_dist; // update to new distance
closest = i_clone; // store it
}
}
}
if(closest != NULL)
{
// than closest is the blueClone that is closest to the event actor
float ang = direction(x, y, closest->x, closest->y); // this is the angle you want
}
Users browsing this forum: Google [Bot] and 1 guest