import java.awt.*;
import java.awt.event.*;
class game0213 extends Frame implements Runnable{
int t;
int x,y;
int m,n;
int map[][]=new int[501][501];
Image off;
Graphics offsc;
public static void main(String [] args) {
Frame f=new game0213();
f.setTitle("game0213");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0213(){
for (m=0;m<501;m++){
for(n=0;n<501;n++){
map[m][n]=1;
}
}
for (m=50;m<451;m++){
for(n=50;n<451;n++){
map[m][n]=2;
}
}
for (m=100;m<400;m++){
for(n=100;n<400;n++){
map[m][n]=3;
}
}
x=260;
y=100;
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=1;
while(t<100){
repaint();
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void update(Graphics g){
paint(g);
}
public void paint(Graphics g){
off = createImage(700, 700);
offsc = off.getGraphics();
for (m=0;m<501;m++){
for(n=0;n<501;n++){
offsc.setColor(Color.red);
if(map[m][n]==1)offsc.fillRect(100+n,600-m,1,1);
offsc.setColor(Color.black);
if(map[m][n]==2)offsc.fillRect(100+n,600-m,1,1);
offsc.setColor(Color.green);
if(map[m][n]==3)offsc.fillRect(100+n,600-m,1,1);
}
}
g.drawImage(off,0,0,this);
}
}
最終更新:2011年02月12日 23:53