I'm new to JAVA, porting a processing sketch over for improvement. I recently decided to change my enemy AI, and make the enemies veer away from the player if they get close. I figured I could accomplish this by moving the enemies targetX and targetY over, depending on their angle to the player. Since I'm not yet familiar with the more advanced trigonometry, I need help with this. Attached is an image visualizing my problem. I need an algorithm to change point A to pint B.

Attachment 3161

If this helps, here is the current AI code:

Code:`// distance from mouse to player`

double distX = Main.myPlayer.getX() - x;

double distY = Main.myPlayer.getY() - y;

// get total distance as one number

double distTotal = Math.sqrt(distX * distX + distY * distY) + 1; // add

// 1 to fix / by 0 problem

// calculate how much to move

double moveDistanceX = turnRadius * distX / distTotal;

double moveDistanceY = turnRadius * distY / distTotal;

// increase current speed

velocityX += moveDistanceX;

velocityY += moveDistanceY;

// get total move distance

double totalMove = Math.sqrt(velocityX * velocityX + velocityY * velocityY);

// apply easing

velocityX = speed * velocityX / totalMove;

velocityY = speed * velocityY / totalMove;

// apply velocity

x += velocityX;

y += velocityY;

// apple angle

angle = -Math.atan2(velocityX, velocityY);