import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class KukkuvPall2 extends Applet implements MouseListener{ int r=10; double koef=10; //10 punkti=1 meeter int maapind=200; int ex(double ox){ return (int)(ox*koef); } int ey(double oy){ return (int)(maapind-oy*koef); } double ox(int ex){ return ex/koef; } double oy(int ey){ return (maapind-ey)/koef; } public KukkuvPall2(){ addMouseListener(this); } double kukkumiseYKoordinaat(double aeg){ return 9.8*aeg*aeg/2; } public void mousePressed(MouseEvent e){ maapind=getHeight(); double ax=ox(e.getX()); double ay=oy(e.getY()); Graphics g=getGraphics(); for(double ky=0, aeg=0; ay>ky; aeg+=0.1, ky=kukkumiseYKoordinaat(aeg)){ g.setColor(Color.black); g.drawOval(ex(ax)-r, ey(ay-ky)-r, 2*r, 2*r); try{Thread.sleep(100);}catch(Exception erind){} g.setColor(Color.white); g.drawOval(ex(ax)-r, ey(ay-ky)-r, 2*r, 2*r); } } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] argumendid){ Frame f=new Frame(); f.add(new KukkuvPall2()); f.setSize(200, 200); f.setVisible(true); } }