basic forumula help?

Some reason this formula doesn’t guide “angle” to “(float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y)))”
Can someone tell me what I’m doing wrong?


if(angle > (float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y))) && 
				angle <= -((float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y)))))
				angle -= handleing;
			
			else if(angle < (float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y))) && 
					angle > -((float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y)))))
					angle += handleing;
			
			x -= Math.sin(Math.toRadians(angle)) * speed;
			y += Math.cos(Math.toRadians(angle)) * speed;

it’s atan2(y, x) not atan2(x, y)

besides the x/y swap, your code hurts my eyes. Why don’t you just write

		float a = (float) Math.toDegrees(Math.atan2(x - target.x, -(y - target.y)));
		if (angle > a && angle <= -a)
			angle -= handleing;
		else if (angle < a && angle > -a)
			angle += handleing;
		x -= Math.sin(Math.toRadians(angle)) * speed;
		y += Math.cos(Math.toRadians(angle)) * speed;