import java.awt.*;
import java.awt.event.*;
class game0410 extends Frame implements Runnable{
double x,y;
double x1,y1;
public static void main(String [] args) {
Frame f=new game0410();
f.setTitle("game[[0410]]");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0410(){
Thread th=
new Thread(this);
th.start();
addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void run(){
double kakudo;
int t;
kakudo=0;
t=1;
while(t<360){
kakudo=kakudo+1;
x1=rotx(kakudo,x,y);
y1=roty(kakudo,x,y);
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
int gx,gy;
gx=(int)x1;
gy=(int)y1;
g.drawLine(200,200,200+gx,200+gy);
}
public static double rotx(double kakudo,double x,double y){
double kaku;
double a1,a2,a3,a4;
double x1,y1;
kaku = kakudo*Math.PI/180;
a1=Math.cos(kaku);
a2=-Math.sin(kaku);
a3=Math.sin(kaku);
a4=Math.cos(kaku);
x1=a1*x+a2*y;
y1=a3*x+a4*y;
return x1;
}
public static double roty(double kakudo,double x,double y){
double kaku;
double a1,a2,a3,a4;
double x1,y1;
kaku = kakudo*Math.PI/180;
a1=Math.cos(kaku);
a2=-Math.sin(kaku);
a3=Math.sin(kaku);
a4=Math.cos(kaku);
x1=a1*x+a2*y;
y1=a3*x+a4*y;
return y1;
}
}
最終更新:2011年02月21日 15:10