import java.awt.*;
import java.awt.event.*;
class game0810 extends Frame implements Runnable {
int fx[]=new int[8];
int fy[]=new int[8];
int s;
int x1,y1;
public static void main(String [] args) {
Frame f=new game0810();
f.setTitle("game0810");
f.setSize(500,500);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0810(){
fx[0]=100;
fy[0]=200;
fx[1]=300;
fy[1]=200;
fx[2]=300;
fy[2]=300;
fx[3]=250;
fy[3]=300;
fx[4]=250;
fy[4]=400;
fx[5]=150;
fy[5]=400;
fx[6]=150;
fy[6]=300;
fx[7]=100;
fy[7]=300;
addWindowListener(new stopwin());
Thread th=new Thread(this);
th.start();
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we)
{System.exit(0);}
}
public void run(){
int t;
double kakudo;
kakudo=0;
t=0;
while(t<10){
kakudo=1;
for (s=0;s<8;s++){
x1=(int)rotx(kakudo,fx[s]-200,fy[s]-400)+200;
y1=(int)roty(kakudo,fx[s]-200,fy[s]-400)+400;
fx[s]=x1;
fy[s]=y1;
}
repaint();
try{
Thread.sleep(2000);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.fillPolygon(fx,fy,8);
g.fillOval(150,350,100,100);
g.fillRect(100,400,200,100);
}
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月28日 23:03