import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import java.io.*;
class
pro extends Frame implements Runnable{
Frame f;
Thread th;
int t,stage,x,y;
int w,h,m,n;
int memor[][]=
new int[500][500];
int memog[][]=new int[500][500];
int memob[][]=new int[500][500];
int mr[][]=new int[500][500];
int mg[][]=new int[500][500];
int mb[][]=new int[500][500];
public static void main(String[] args){
Frame f=new pro();
f.setTitle("pro");
f.setSize(800,800);
f.setBackground(Color.yellow);
f.show();
}
pro() {
addWindowListener(new stopwin());
setLayout(new FlowLayout());
Button bu1 = new Button("z1");
bu1.addActionListener(new beck());
add(bu1);
bu1.setActionCommand("c1");
Button bu2 = new Button("z2");
bu2.addActionListener(new beck());
add(bu2);
bu2.setActionCommand("c2");
w=500;
h=500;
try{
BufferedReader br =new BufferedReader(new FileReader("cam.
txt"));
String[] test = new String[w*h];
String str;
String x[]=new String[5];
for(int i=0; i<w*h; i++){
str = br.readLine();
x=str.split(",");
m=Integer.valueOf(x[0]);
n=Integer.valueOf(x[1]);
memor[m][n]=Integer.valueOf(x[2]);
memog[m][n]=Integer.valueOf(x[3]);
memob[m][n]=Integer.valueOf(x[4]);
}
br.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br2 =new BufferedReader(new FileReader("girl.txt"));
String str2;
String y[]=new String[5];
for(int i=0; i<w*h; i++){
str2 = br2.readLine();
y=str2.split(",");
m=Integer.valueOf(y[0]);
n=Integer.valueOf(y[1]);
mr[m][n]=Integer.valueOf(y[2]);
mg[m][n]=Integer.valueOf(y[3]);
mb[m][n]=Integer.valueOf(y[4]);
}
br2.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
stage=1;
x=200;
y=0;
th=new Thread(this);
th.start();
}
class beck implements ActionListener {
public void actionPerformed(ActionEvent e) {
if ("c1".equals(e.getActionCommand()))stage=1;
if ("c2".equals(e.getActionCommand()))stage=2;
}
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void paint( Graphics g ) {
int cc;
g.setColor(Color.yellow);
g.fillRect(0,0,800,800);
g.setColor(Color.blue);
for (m=0;m<h;m++){
for (n=0;n<w;n++){
cc=0;
if(mr[m][n]<200)cc=cc+1;
if(mg[m][n]<200)cc=cc+1;
if(mb[m][n]<200)cc=cc+1;
if (stage==1)cc=cc+1;
if(cc==4)g.fillRect(
100+n,100+m,1,1);
}
}
g.setColor(Color.red);
for (m=0;m<h;m++){
for (n=0;n<w;n++){
cc=0;
if(memor[m][n]<200)cc=cc+1;
if(memog[m][n]<200)cc=cc+1;
if(memob[m][n]<200)cc=cc+1;
if (stage==2)cc=cc+1;
if(cc==4)g.fillRect(100+n,100+m,1,1);
}
}
g.setColor(Color.white);
g.fillRect(500,100,200,50);
g.setColor(Color.black);
if (stage==1)g.drawString("私かわいい",510,110);
if (stage==2)g.drawString("ぬいでもすごいでしょう",510,110);
}
public void update(Graphics g) {
paint(g);
}
public void run() {
while(t<1000){
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
t=t+1;
}
}
}
最終更新:2010年10月19日 17:57