アットウィキロゴ

pろ0208

import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;

class pro0208 extends Frame implements Runnable{

Frame f;
Thread th;
int gun;
int t;
int mx[]=new int[100];
int my[]=new int[100];
public static void main(String[] args){
Frame f=new pro0208();
f.setTitle("pro0208");
f.setSize(600,600);
f.setBackground(Color.yellow);
f.show();
}

pro0208() {
addWindowListener(new stopwin());
gun=5;
t=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 sp,t2;
g.setColor(Color.yellow);
g.fillRect(0,0,600,600);
g.setColor(Color.red);
g.fillRect(50*gun,500,10,10);
sp=t-10;
if (sp<1)sp=1;
for (t2=sp;t2<t;t2++){
g.setColor(Color.blue);
g.fillRect(50*mx[t2],500-50*my[t2],5,5);
}

}

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

public void run() {
int dg;
int start;
int t1;
for (t=1;t<100;t++){
dg=1;
if (Math.random()>0.5)dg=-1;
gun=gun+dg;
mx[t]=gun;
my[t]=0;
start=t-10;
if (start<1)start=1;
for (t1=start;t1<t;t1++){
my[t1]=my[t1]+1;
}
repaint();
try{th.sleep(1000);} catch(InterruptedException e) { }
}
}

}
最終更新:2010年09月19日 20:18