Thanks Boot_WB, very interesting. I did consider calculating which quadrant the object is in and adding a multiple of 90 degrees to compensate, but fortunately atan2(x,y) does the hard work for me.
Now, here's another problem. The following code is supposed to move an object towards the player:
//Find the angle required to move towards the player
int distx = playerx-x;
int disty = playery-y;
int angle = atan2( disty, distx) * 57.29578;
//Set the velocities
dx = seekerspeed * cos(angle);
dy = seekerspeed * sin(angle);
//Move
x+=dx;
y+=dy;
As you can see in
this Quicktime video, the effects aren't quite as desired. The enemy stops when it gets close to the player instead of attempting to collide with it, and if the player moves the enemy actually seems to move away from it!
--
moto