import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
class game0317 extends Frame implements Runnable{
int t;
int mx,nx;
int w=250;
int h=375;
int rgb[][]=new int[h][w];
Image buf;
Graphics bufsc;
public static void main(String [] args) {
Frame f=new game0317();
f.setTitle("game0317");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0317(){
csvdata();
Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void run(){
t=0;
while(t<30){
repaint();
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint( Graphics g ) {
buf = createImage(600,600);
bufsc = buf.getGraphics();
for (mx=0;mx<h;mx++){
for (nx=0;nx<w;nx++){
bufsc.setColor(Color.red);
if (rgb[mx][nx]>50)bufsc.fillRect(nx+5*t,mx+5*t,1,1);
}
}
g.drawImage(buf,0,0,this);
}
public void csvdata(){
int n;
String s;
String a[]=new String[w*h];
String b[]=new String[3];
try {
n=0;
FileReader fr = new FileReader("data0309.csv");
BufferedReader br = new BufferedReader(fr);
while((s = br.readLine()) != null) {
a[n]=s;
n=n+1;
}
fr.close();
} catch (IOException e) {System.out.println(e);}
for (n=0;n<w*h;n++){
b=a[n].split(",");
mx=Integer.valueOf(b[0]);
nx=Integer.valueOf(b[1]);
rgb[mx][nx]=Integer.valueOf(b[2]);
}
}
}
最終更新:2011年02月19日 01:57