import java.awt.*;
import java.awt.event.*;
class game0809 extends Frame implements Runnable {
int fx[]=new int[4];
int fy[]=new int[4];
int s;
int x1,y1;
public static void main(String [] args) {
Frame f=new game0809();
f.setTitle("game0808");
f.setSize(500,500);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0809(){
fx[0]=100;
fy[0]=100;
fx[1]=200;
fy[1]=100;
fx[2]=200;
fy[2]=300;
fx[3]=100;
fy[3]=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=6;
for (s=0;s<4;s++){
x1=(int)rotx(kakudo,fx[s]-150,fy[s]-100)+150;
y1=(int)roty(kakudo,fx[s]-150,fy[s]-100)+100;
fx[s]=x1;
fy[s]=y1;
}
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.fillPolygon(fx,fy,4);
g.fillOval(100,50,100,100);
g.fillRect(100,50,100,50);
}
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日 22:43