src/app/OglyPane.java
/*
     * This method makes Ogly's pupils track the mouse.
     * Read "docs/Do The Math.pdf" if you want to understand how this works.
     */
This method makes Ogly's pupils track the mouse.
Read "docs/Do The Math.pdf" if you want to understand how this works.
This method makes Ogly ' s pupils track the mouse . Read " docs / Do The Math . pdf " if you want to understand how this works .
@FXML private void mouseMoved(MouseEvent e) {
        double ep = m.getEyeRadius() - m.getPupilRadius();
        double ea = e.getX() - leftEye.getCenterX();
        double ma = e.getY() - leftEye.getCenterY();
        double em = Math.sqrt(ea * ea + ma * ma);
        if (em < m.getEyeRadius() - m.getPupilRadius()) {
            leftPupil.setCenterX(e.getX());
            leftPupil.setCenterY(e.getY());
        } else {
            leftPupil.setCenterX(leftEye.getCenterX() + ea * ep / em);
            leftPupil.setCenterY(leftEye.getCenterY() + ma * ep / em);
        }
        ea = e.getX() - rightEye.getCenterX();
        ma = e.getY() - rightEye.getCenterY();
        em = Math.sqrt(ea * ea + ma * ma);
        if (em < m.getEyeRadius() - m.getPupilRadius()) {
            rightPupil.setCenterX(e.getX());
            rightPupil.setCenterY(e.getY());
        } else {
            rightPupil.setCenterX(rightEye.getCenterX() + ea * ep / em);
            rightPupil.setCenterY(rightEye.getCenterY() + ma * ep / em);
        }
    }
@ FXML private void mouseMoved ( MouseEvent e ) { double ep = m . getEyeRadius ( ) - m . getPupilRadius ( ) ; double ea = e . getX ( ) - leftEye . getCenterX ( ) ; double ma = e . getY ( ) - leftEye . getCenterY ( ) ; double em = Math . sqrt ( ea * ea + ma * ma ) ; if ( em < m . getEyeRadius ( ) - m . getPupilRadius ( ) ) { leftPupil . setCenterX ( e . getX ( ) ) ; leftPupil . setCenterY ( e . getY ( ) ) ; } else { leftPupil . setCenterX ( leftEye . getCenterX ( ) + ea * ep / em ) ; leftPupil . setCenterY ( leftEye . getCenterY ( ) + ma * ep / em ) ; } ea = e . getX ( ) - rightEye . getCenterX ( ) ; ma = e . getY ( ) - rightEye . getCenterY ( ) ; em = Math . sqrt ( ea * ea + ma * ma ) ; if ( em < m . getEyeRadius ( ) - m . getPupilRadius ( ) ) { rightPupil . setCenterX ( e . getX ( ) ) ; rightPupil . setCenterY ( e . getY ( ) ) ; } else { rightPupil . setCenterX ( rightEye . getCenterX ( ) + ea * ep / em ) ; rightPupil . setCenterY ( rightEye . getCenterY ( ) + ma * ep / em ) ; } }
This method makes Ogly's pupils track the mouse.
This method makes Ogly ' s pupils track the mouse .