Finding the direction to another object
OK, I need to find the direction to the closest player for the AI code in a game that I am making. I thought you were supposed to use the atan2() function for that, but it doesn't work. The worm (that's what the AI is for) just keeps pointing downward or to the sides.
Maybe I'm using the function wrong:
playerDir = atan2( closestToMe->pos.x - pos.x,
closestToMe->pos.y - pos.y);
I've tried switching the x and the y, that didn't work. I'm expecting the function to return the direction in radians, that's how it works right? I'm using allegro and Dev-C++, don't think that matters. Please Help!