Original Post
I Have created an oval (200, 200, 100, 100). does anyone know the formula, to figure out if the user's click was inside the circle?
Point center=new Point(oval.getX()+oval.getWidth()/2,oval.getY()+oval.getHeight()/2);int radius=oval.getWidth()/2;Point mouseClick=getMouseClickedCoords();/*distance formula*/int distanceFromCenter=Math.sqrt(Math.pow(center.getX()-mouseClick.getX(),2)+Math.pow(center.getY()-mouseClick.getY(),2));if(distanceFromCenter<=radius) //inside the circleelse //outside the circleThis topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more