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 select;
int memor[][][]=
new int[7][500][500];
int memog[][][]=new int[7][500][500];
int memob[][][]=new int[7][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("A");
bu1.addActionListener(new beck());
add(bu1);
bu1.setActionCommand("c1");
Button bu2 = new Button("B");
bu2.addActionListener(new beck());
add(bu2);
bu2.setActionCommand("c2");
w=500;
h=500;
try{
BufferedReader br =new BufferedReader(new FileReader("ch1.
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[1][m][n]=Integer.valueOf(x[2]);
memog[1][m][n]=Integer.valueOf(x[3]);
memob[1][m][n]=Integer.valueOf(x[4]);
}
br.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br2 =new BufferedReader(new FileReader("ch2.txt"));
String str2;
String x2[]=new String[5];
for(int i=0; i<w*h; i++){
str2 = br2.readLine();
x2=str2.split(",");
m=Integer.valueOf(x2[0]);
n=Integer.valueOf(x2[1]);
memor[2][m][n]=Integer.valueOf(x2[2]);
memog[2][m][n]=Integer.valueOf(x2[3]);
memob[2][m][n]=Integer.valueOf(x2[4]);
}
br2.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br3 =new BufferedReader(new FileReader("ch3.txt"));
String str3;
String x3[]=new String[5];
for(int i=0; i<w*h; i++){
str3 = br3.readLine();
x3=str3.split(",");
m=Integer.valueOf(x3[0]);
n=Integer.valueOf(x3[1]);
memor[3][m][n]=Integer.valueOf(x3[2]);
memog[3][m][n]=Integer.valueOf(x3[3]);
memob[3][m][n]=Integer.valueOf(x3[4]);
}
br3.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br4 =new BufferedReader(new FileReader("ch4.txt"));
String str4;
String x4[]=new String[5];
for(int i=0; i<w*h; i++){
str4 = br4.readLine();
x4=str4.split(",");
m=Integer.valueOf(x4[0]);
n=Integer.valueOf(x4[1]);
memor[4][m][n]=Integer.valueOf(x4[2]);
memog[4][m][n]=Integer.valueOf(x4[3]);
memob[4][m][n]=Integer.valueOf(x4[4]);
}
br4.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br5 =new BufferedReader(new FileReader("ch5.txt"));
String str5;
String x5[]=new String[5];
for(int i=0; i<w*h; i++){
str5 = br5.readLine();
x5=str5.split(",");
m=Integer.valueOf(x5[0]);
n=Integer.valueOf(x5[1]);
memor[5][m][n]=Integer.valueOf(x5[2]);
memog[5][m][n]=Integer.valueOf(x5[3]);
memob[5][m][n]=Integer.valueOf(x5[4]);
}
br5.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
try{
BufferedReader br6 =new BufferedReader(new FileReader("ch6.txt"));
String str6;
String x6[]=new String[5];
for(int i=0; i<w*h; i++){
str6 = br6.readLine();
x6=str6.split(",");
m=Integer.valueOf(x6[0]);
n=Integer.valueOf(x6[1]);
memor[6][m][n]=Integer.valueOf(x6[2]);
memog[6][m][n]=Integer.valueOf(x6[3]);
memob[6][m][n]=Integer.valueOf(x6[4]);
}
br6.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
stage=1;
x=200;
y=0;
select=3;
th=new Thread(this);
th.start();
}
class beck implements ActionListener {
public void actionPerformed(ActionEvent e) {
if ("c1".equals(e.getActionCommand()))select=1;
if ("c2".equals(e.getActionCommand()))select=2;
}
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void paint( Graphics g ) {
int cc,j;
g.setColor(Color.yellow);
g.fillRect(0,0,800,800);
g.setColor(Color.black);
g.drawRect(
100,100,300,500);
j=0;
if (stage==1)j=j+1;
if (select==1)j=j+1;
if (j==2)stage=2;
if (j==2)select=3;
j=0;
if (stage==1)j=j+1;
if (select==2)j=j+1;
if (j==2)stage=3;
if (j==2)select=3;
j=0;
if (stage==2)j=j+1;
if (select==1)j=j+1;
if (j==2)stage=4;
if (j==2)select=3;
j=0;
if (stage==2)j=j+1;
if (select==2)j=j+1;
if (j==2)stage=5;
if (j==2)select=3;
j=0;
if (stage==3)j=j+1;
if (select==1)j=j+1;
if (j==2)stage=5;
if (j==2)select=3;
j=0;
if (stage==3)j=j+1;
if (select==2)j=j+1;
if (j==2)stage=6;
if (j==2)select=3;
select=3;
g.setColor(Color.blue);
for (m=0;m<h;m++){
for (n=0;n<w;n++){
cc=0;
if(memor[stage][m][n]<200)cc=cc+1;
if(memog[stage][m][n]<200)cc=cc+1;
if(memob[stage][m][n]<200)cc=cc+1;
if(cc==3)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);
if (stage==3)g.drawString("何で、そんなこと言うの",510,110);
if (stage==4)g.drawString("うそつき",510,110);
if (stage==5)g.drawString("大好き",510,110);
if (stage==6)g.drawString("正直者は嫌い",510,110);
g.setColor(Color.white);
if (stage<4)g.fillRect(500,200,200,50);
g.setColor(Color.black);
if (stage==1)g.drawString("A かわいいよ",510,210);
if (stage==2)g.drawString("A 好きだよ",510,210);
if (stage==3)g.drawString("A 嘘だよ",510,210);
g.setColor(Color.white);
if (stage<4)g.fillRect(500,300,200,50);
g.setColor(Color.black);
if (stage==1)g.drawString("B かわいくない",510,310);
if (stage==2)g.drawString("B 別に",510,310);
if (stage==3)g.drawString("B 本当のことを言っただけだよ",510,310);
}
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月20日 02:29