アットウィキロゴ

JAVA3djj

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,x,y;
int w,h,m,n;

int memor[][]=new int[657][232];
int memog[][]=new int[657][232];
int memob[][]=new int[657][232];

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());
w=232;
h=657;


try{
BufferedReader br =new BufferedReader(new FileReader("test.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("入出力エラーです。");}
t=0;
x=0;
y=0;
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;
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(memor[m][n]<200)cc=cc+1;
if(memog[m][n]<200)cc=cc+1;
if(memob[m][n]<200)cc=cc+1;
if(cc==3)g.drawRect(x+n,y+m,1,1);
}
}

}

public void update(Graphics g) {
paint(g);
}

public void run() {
while (t<1000){
x=x+(int)(50*Math.random())-25;
y=y+(int)(30*Math.random())-15;
if (x>500)x=500;
if (y>500)y=500;
if (x<100)x=100;
if (y<100)y=100;
repaint();
try{th.sleep(100);} catch(InterruptedException e) { }
t=t+1;
}
}

}
最終更新:2010年10月18日 03:44