import java.awt.*;
import java.awt.event.*;
class game0806 extends Frame {
int m,n,mx,nx;
int robot[][]=new int[101][101];
int face[][]=new int[101][101];
int kubi[][]=new int[101][101];
int chface[][]=new int[101][101];
int chkubi[][]=new int[101][101];
int j;
public static void main(String [] args) {
Frame f=new game0806();
f.setTitle("game0806");
f.setSize(500,500);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0806(){
addWindowListener(new stopwin());
for (m=20;m<30;m++){
for (n=40;n<60;n++){
face[m][n]=100;
}
}
for (m=20;m<30;m++){
for (n=40;n<60;n++){
mx=(int)roty(30,n-50,m-40)+40;
nx=(int)rotx(30,n-50,m-40)+50;
chface[mx][nx]=100;
}
}
for (m=30;m<60;m++){
for (n=45;n<55;n++){
kubi[m][n]=100;
}
}
for (m=30;m<60;m++){
for (n=45;n<55;n++){
mx=(int)roty(30,n-50,m-40)+40;
nx=(int)rotx(30,n-50,m-40)+50;
chkubi[mx][nx]=100;
}
}
for (m=0;m<101;m++){
for (n=0;n<101;n++){
robot[m][n]=chkubi[m][n];
}
}
for (m=40;m<70;m++){
for (n=30;n<70;n++){
robot[m][n]=100;
}
}
for (m=70;m<90;m++){
for (n=35;n<45;n++){
robot[m][n]=100;
}
}
for (m=70;m<90;m++){
for (n=55;n<65;n++){
robot[m][n]=100;
}
}
for (m=40;m<60;m++){
for (n=20;n<30;n++){
robot[m][n]=100;
}
}
for (m=40;m<60;m++){
for (n=70;n<80;n++){
robot[m][n]=100;
}
}
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we)
{System.exit(0);}
}
public void paint(Graphics g){
g.setColor(Color.blue);
for (m=0;m<101;m++){
for (n=0;n<101;n++){
if(robot[m][n]>50)g.fillRect(5*n,5*m,5,5);
}
}
g.setColor(Color.red);
for (m=0;m<101;m++){
for (n=0;n<101;n++){
if(chface[m][n]>50)g.fillRect(5*n,5*m,5,5);
}
}
}
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日 20:21