import java.awt.*; public class Liigu3 extends Frame implements Runnable{ double nurk=0; double raadius=50; int samm=1; int ooteaeg=10; //ms boolean veel=true; public Liigu3(){ super("Ringike"); setSize(300, 300); setVisible(true); new Thread(this).start(); } public int x=10; public int y=150; boolean suund=true; public int kaed=13; public void joonista(){ Graphics g=this.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); if(x>(getSize().width-10)) suund=false; else{} if(suund==false) x=x-samm; else{x=x+samm;} if(x<10)suund=true; /* if(kaed==13)kaed=10; else{kaed=13;} */ kaed=(int)(10+3*Math.sin(x/5.0)); g.setColor(Color.black); g.drawOval(x-5, y-5, 10, 10); g.drawLine(x, y+5, x, y+20); g.drawLine(x, y+10, x-8, y+kaed); g.drawLine(x, y+10, x+8, y+kaed); g.drawLine(x, y+20, x+8, y+23); g.drawLine(x, y+20, x-8, y+23); // g.drawOval( // keskx+(int)(raadius*Math.cos(nurk))-5, // kesky+(int)(raadius*Math.sin(nurk))-5, // 10, 10 // ); System.out.println(x); } public void run(){ while(veel){ joonista(); try{ Thread.sleep(ooteaeg); } catch(Exception e){e.printStackTrace();} } } public static void main(String argumendid[]){ new Liigu3(); } }