import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import javax.sound.sampled.*;
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("movie");
f.setSize(600,600);
f.setBackground(Color.yellow);
f.show();
}
pro() {
addWindowListener(new stopwin());
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;
th=new Thread(this);
th.start();
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void paint( Graphics g ) {
int cc,j;
g.setColor(Color.blue);
g.fillRect(0,0,600,600);
g.setColor(Color.yellow);
g.fillRect(50,50,500,500);
g.setColor(Color.black);
g.drawRect(50,50,500,500);
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(50+n,50+m,1,1);
}
}
}
public void update(Graphics g) {
paint(g);
}
public void run() {
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
stage=2;
repaint();
try {URL url = this.getClass().getClassLoader().getResource("sound.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();}
catch (UnsupportedAudioFileException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
catch (LineUnavailableException e) {e.printStackTrace();}
try{th.sleep(3000);} catch(InterruptedException e) { }
stage=3;
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
repaint();
stage=5;
try{th.sleep(1000);} catch(InterruptedException e) { }
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
stage=6;
repaint();
try {URL url = this.getClass().getClassLoader().getResource("sp.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();}
catch (UnsupportedAudioFileException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
catch (LineUnavailableException e) {e.printStackTrace();}
}
}
最終更新:2010年10月20日 22:09