import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.util.Vector; public class animatsioon extends Applet implements ActionListener{ Graphics g; int x=12, y=12, kiirus=30; int rx=x-10, ry=y-10, xl=16, yl=16; TextField tf=new TextField("30"); public animatsioon(){ setLayout(new BorderLayout()); add(tf, BorderLayout.SOUTH); tf.addActionListener(this); } public void paint(Graphics g){ //ymbritsevad seinad g.drawLine(0, 20, 0, 220); //ü-a vasak sein g.drawLine(220, 0, 220, 220); //ü-a parem sein g.drawLine(0, 0, 220, 0); //p-v ylemine sein g.drawLine(20, 220, 220, 220); //p-v alumine sein //vasakult paremale g.drawLine(0, 20, 80, 20); //v-p g.drawLine(0, 40, 20, 40); //v-p g.drawLine(0, 140, 40, 140); //v-p g.drawLine(20, 120, 40, 120); //v-p g.drawLine(40, 40, 60, 40); //v-p g.drawLine(40, 100, 60, 100); //v-p g.drawLine(40, 160, 100, 160); //v-p g.drawLine(60, 60, 80, 60); //v-p g.drawLine(80, 100, 100, 100); //v-p g.drawLine(80, 140, 120, 140); //v-p g.drawLine(100, 80, 140, 80); //v-p g.drawLine(80, 180, 120, 180); //v-p g.drawLine(100, 200, 140, 200); //v-p g.drawLine(120, 100, 160, 100); //v-p g.drawLine(140, 20, 200, 20); //v-p g.drawLine(140, 60, 200, 60); //v-p g.drawLine(140, 120, 160, 120); //v-p g.drawLine(160, 40, 220, 40); //v-p g.drawLine(160, 80, 180, 80); //v-p g.drawLine(180, 160, 200, 160); //v-p //ylevalt alla g.drawLine(20, 40, 20, 60); //y_a g.drawLine(20, 80, 20, 120); //y_a g.drawLine(20, 160, 20, 220); //y-a g.drawLine(40, 40, 40, 100); //y_a g.drawLine(40, 120, 40, 200); //y_a g.drawLine(60, 80, 60, 160); //y_a g.drawLine(60, 180, 60, 220); //y_a g.drawLine(80, 20, 80, 80); //y_a g.drawLine(80, 100, 80, 140); //y_a g.drawLine(80, 160, 80, 200); //y_a g.drawLine(100, 0, 100, 60); //y_a g.drawLine(100, 80, 100, 120); //y_a g.drawLine(120, 20, 120, 80); //y_a g.drawLine(120, 100, 120, 180); //y_a g.drawLine(140, 0, 140, 60); //y_a g.drawLine(140, 120, 140, 220); //y_a g.drawLine(160, 140, 160, 200); //y_a g.drawLine(180, 80, 180, 220); //y_a g.drawLine(200, 60, 200, 100); //y_a g.drawLine(200, 120, 200, 200); //y_a } public void keyPressed(KeyEvent k){ } public void actionPerformed(ActionEvent ev){ kiirus=Integer.parseInt(tf.getText().trim()); repaint(); x=10; y=10; for(int x=0; x<85; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=90; y=10; for(int x=90; y<70; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+5); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=90; y=70; for(int y=70; x<110; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=110; y=70; for(int x=110; y>10; y=y-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y-5); y=y-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=110; y=10; for(int y=10; x<130; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=130; y=10; for(int x=130; y<70; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+5); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=130; y=70; for(int y=70; x<150; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=150; y=70; for(int x=150; y<90; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+6); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=150; y=90; for(int y=90; x<170; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=170; y=90; for(int x=170; y<110; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+6); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=170; y=110; for(int y=110; x>130; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=130; y=110; for(int x=130; y<190; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+6); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=130; y=190; for(int y=190; x>90; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=90; y=190; for(int x=90; y<210; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+5); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=90; y=210; for(int y=210; x>70; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=70; y=210; for(int x=70; y>170; y=y-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y-5); y=y-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=70; y=170; for(int y=170; x>50; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=50; y=170; for(int x=50; y<210; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+5); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=50; y=210; for(int y=210; x>30; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=30; y=210; for(int x=30; y>150; y=y-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y-5); y=y-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=30; y=150; for(int y=150; x>10; x=x-2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x-5, y); x=x-2; try{Thread.sleep(kiirus);}catch(Exception e){} } x=10; y=150; for(int x=10; y<230; y=y+2){ Graphics g=getGraphics(); g.setColor(Color.blue); g.drawLine(x, y, x, y+5); y=y+2; try{Thread.sleep(kiirus);}catch(Exception e){} } System.out.println("Finis!"); /* x=10; y=230; for(int x=10; x<301; x=x+2){ Graphics g=getGraphics(); g.setColor(Color.green); g.drawLine(x, y, x+5, y); x=x+2; try{Thread.sleep(kiirus);}catch(Exception e){} }*/ // } } /* if(kood==KeyEvent.VK_LEFT){ x=x-20; x=x-20; } if(kood==KeyEvent.VK_UP){ y=y-20; } if(kood==KeyEvent.VK_DOWN){ y=y+20; }*/ public void keyReleased(KeyEvent k){} public void keyTyped(KeyEvent k){} public static void main(String argumendid[]){ Frame f=new Frame("Labürint"); f.add(new animatsioon()); f.setSize(300, 300); f.setVisible(true); } }