I need to use the distance formula to check the distance between my mouse and a moving object. However, my totalDistance continues to return only 1 and I am not sure why.
float mouseX = Engine.getMouseX(); //gets X coordinate of the mouse
float mouseY = Engine.getMouseY(); //gets Y coordinate of the mouse
graphic.setDirection(mouseX,mouseY); //object faces mouse
float currentX = graphic.getX(); //gets X coordinate of object
float currentY = graphic.getY(); ////gets Y coordinate of object
double distanceX = (Math.pow((currentX - mouseX), 2)); //calculate (x2-x1)^2
double distanceY= (Math.pow((currentY - mouseY), 2)); //calculate (y2-y1)^2
double totalDistance = (Math.pow((distanceX+distanceY), (1/2)));
//calculate square root of distance 1 + distance 2
System.out.println("totalDistance = "+totalDistance); //prints distance