import java.applet.Applet; import java.awt.*; public class UpdatedEyes extends Applet { double lx=150, ly=150, rx=260, ry=150; double lastlx=150, lastly=150, lastrx=260, lastry=150; public void update (Graphics g) { g.setColor(Color.white); g.fillOval((int)(lastlx-8), (int)(lastly-8), 16, 16); g.fillOval((int)(lastrx-8), (int)(lastry-8), 16, 16); g.setColor(Color.black); g.fillOval((int)(lx-8), (int)(ly-8), 16, 16); g.fillOval((int)(rx-8), (int)(ry-8), 16, 16); lastlx = lx; lastly = ly; lastrx = rx; lastry = ry; } public void paint (Graphics g) { g.setColor(Color.white); g.fillOval(100, 100, 100, 100); g.fillOval(210, 100, 100, 100); } public boolean mouseMove (Event evt, int x, int y){ double X=x, Y=y; double k = scale(X-150, Y-150); lx = k*(X-150)+150; ly = k*(Y-150)+150; k = scale(X-260, Y-150); rx = k*(X-260)+260; ry = k*(Y-150)+150; repaint(); return true; } public double scale (double x, double y){ return 42 / Math.sqrt(x*x+y*y+1764); } }