import java.awt.*;
import java.awt.event.*;
class game0412 extends Frame implements Runnable{
int s;
double x[]=new double[11];
double y[]=new double[11];
double x1[]=new double[11];
double y1[]=new double[11];
public static void main(String [] args) {
Frame f=new game0412();
f.setTitle("game0412");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0412(){
for(s=1;s<11;s++){
x[s]=10*s;
y[s]=10*s;
}
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;
for(s=1;s<11;s++){
x1[s]=rotx(kakudo,x[s],y[s]);
y1[s]=roty(kakudo,x[s],y[s]);
}
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
int gx,gy;
for(s=1;s<11;s++){
gx=(int)x1[s];
gy=(int)y1[s];
g.fillRect(100+gx,600-gy,10,10);
}
}
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:32