アットウィキロゴ

java0418

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

class game0418 extends Frame{
PixelGrabber pg;
Color col;
Image img;
int w=297;
int h=450;
int pix[]=new int[w*h];
int red,green,blue;
int memor[][]=new int[h][w];
int memog[][]=new int[h][w];
int memob[][]=new int[h][w];
int body[][]=new int[h][w];
int atama[][]=new int[h][w];
int m,n,mx,nx,mxs,nxs;
int num;
String s1,s2,s3,s4;

game0418() {

s1="atama.jpg";
catchimg(s1);
changea();

s2="point.jpg";
catchimg(s2);
check();

System.out.println(mxs);
System.out.println(nxs);

}

public static void main(String[] args) {
game0418 f = new game0418();
f.setSize(700,700);
f.setBackground(Color.blue) ;
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){public void
windowClosing(WindowEvent e){System.exit(0);}});
}

public void paint( Graphics g ) {
int i,z,pp;
g.setColor(Color.blue);
g.fillRect(0,0,700,700);

mx=1;
nx=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
g.setColor(Color.blue);
g.fillRect(100+nxs,100+mxs,5,5);
g.setColor(new Color(memor[mx][nx],memog[mx][nx],memob[mx][nx]));
g.fillRect(100+nx,100+mx,1,1);
}
}
}

void catchimg(String s){

img = createImage(w,h);
img = Toolkit.getDefaultToolkit().getImage(s);
pg = new PixelGrabber(img,0,0,w,h,pix,0,w);

try{pg.grabPixels();}catch(InterruptedException ie){}
m=0;
n=0;
for(int i=0;i<w*h;i++){
int p = pix[i];
col=new Color(pix[i]);
red=col.getRed();
green=col.getGreen();
blue=col.getBlue();
memor[m][n]=red;
memog[m][n]=green;
memob[m][n]=blue;
n=n+1;
if (n==w)m=m+1;
if (n==w)n=0;
}
}

void changea(){
int j;
mx=1;
nx=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
j=0;
if(memor[mx][nx]>50)j=j+1;
if(memog[mx][nx]>50)j=j+1;
if(memob[mx][nx]>50)j=j+1;
if(j==3)atama[mx][nx]=100;
}
}

}


void changeb(){
int j;
mx=1;
nx=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
j=0;
if(memor[mx][nx]>50)j=j+1;
if(memog[mx][nx]>50)j=j+1;
if(memob[mx][nx]>50)j=j+1;
if(j==3)body[mx][nx]=100;
}
}

}

void check(){
int j;
mxs=1;
nxs=1;
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
j=0;
if(memor[mx][nx]<20)j=j+1;
if(memog[mx][nx]<20)j=j+1;
if(memob[mx][nx]<20)j=j+1;
if(j==3)mxs=mx;
if(j==3)nxs=nx;
}
}

}

public static int seekmapm(double kakudo,int m,int n,int ms,int ns){
int m1,n1;
double m2,n2;
m1=m-ms;
n1=n-ns;
m2=rotx(kakudo,m1,n1);
n2=roty(kakudo,m1,n1);
return (int)m2+ms;
}

public static int seekmapn(double kakudo,int m,int n,int ms,int ns){
int m1,n1;
double m2,n2;
m1=m-ms;
n1=n-ns;
m2=rotx(kakudo,m1,n1);
n2=roty(kakudo,m1,n1);
return (int)n2+ns;
}


public static double rotx(double kakudo,int x,int 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,int x,int 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月22日 06:10