import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Graphics;
public class Wind extends Applet implements Runnable{
int Theta;
int x11=0,y11=0,x12=0,y12=0,x21=0,y21=0,x22=0,y22=0;
@Override
public void run() {
while(true){
Dimension d=getSize();
x11=150+(int)(100*Math.cos(Math.toRadians(Theta)));
y11=150+(int)(100*Math.sin(Math.toRadians(Theta)));
x12=150+(int)(100*Math.cos(Math.toRadians(Theta+180)));
y12=150+(int)(100*Math.sin(Math.toRadians(Theta+180)));
x21=150+(int)(100*Math.cos(Math.toRadians(Theta+90)));
y21=150+(int)(100*Math.sin(Math.toRadians(Theta+90)));
x22=150+(int)(100*Math.cos(Math.toRadians(Theta+270)));
y22=150+(int)(100*Math.sin(Math.toRadians(Theta+270)));
Theta++;
try{
Thread.sleep(3);
repaint();
}
catch(Exception e){
}
}
}
@Override
public void init(){
Thread t1=new Thread(this);
t1.start();
}
@Override
public void paint(Graphics g){
g.drawLine(x11,y11,x12,y12);
g.drawLine(x21,y21,x22,y22);
}
}
OUTPUT
No comments:
Post a Comment