import java.awt.*;
import java.awt.event.*;
class game0419 extends Frame implements Runnable{
double x,y,z;
double rx,ry;
public static void main(String [] args) {
Frame f=new game0419();
f.setTitle("game0419");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0419(){
x=100;
y=0;
z=0;
rot(x,y,z);
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(){
int t;
t=1;
while(t<100){
repaint();
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
int gx1,gy1;
gx1=seekgx(rx);
gy1=seekgy(ry);
g.drawLine(100,400,gx1,gy1);
}
public int seekgx(double x){
return (int)(100+x);
}
public int seekgy(double y){
return (int)(400-y);
}
public void rot(double x,double y,double z){
double theta,phi;
double a1,a2,a3,a4;
theta = -40*Math.PI/180;
phi=60*Math.PI/180;
a1=Math.cos(theta);
a2=Math.sin(theta);
a3=Math.cos(phi);
a4=Math.sin(phi);
rx=-a2*x+a1*y;
ry=-a1*a4*x-a2*a3*y+a4*z;
}
}
最終更新:2011年02月22日 09:14