アットウィキロゴ

0808j

import java.awt.*;
import java.awt.event.*;


class game0808 extends Frame {

int fx[]=new int[4];
int fy[]=new int[4];
int s;
int x1,y1;

public static void main(String [] args) {
        Frame f=new game0808();
        f.setTitle("game0808");
        f.setSize(500,500);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

game0808(){

fx[0]=100;
fy[0]=100;
fx[1]=200;
fy[1]=100;
fx[2]=200;
fy[2]=300;
fx[3]=100;
fy[3]=300;

for (s=0;s<4;s++){
x1=(int)rotx(-60,fx[s]-150,fy[s]-100)+150;
y1=(int)roty(-60,fx[s]-150,fy[s]-100)+100;
fx[s]=x1;
fy[s]=y1;
}

addWindowListener(new stopwin());



}

class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we)
{System.exit(0);}
}    

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:32