アットウィキロゴ

がめ02 がm

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

class game02 extends Frame implements Runnable{

int t;
int m;
int gun;
int dg;
int mx[]=new int[501];
int my[]=new int[501];
int mz[]=new int[501];

public static void main(String [] args) {
        Frame f=new game02();
        f.setTitle("game02");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

game02(){


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;
dg=1;
gun=5;
while(t<500){
dg=1;
if (Math.random()>0.5)dg=-1;
gun=gun+dg;

if (gun<1)gun=1;
if (gun>10)gun=10;

mx[t]=gun;
my[t]=0;
mz[t]=1;

for (m=1;m<t;m++){
my[m]=my[m]+1;
}


repaint();
try{
Thread.sleep(500);
}catch(InterruptedException e){}
t=t+1;
}

}


public void paint(Graphics g){
g.fillRect(100+50*gun,600,50,50);
for (m=1;m<t;m++){
g.fillRect(100+50*mx[m],500-50*my[m],10,10);
}



}

}
最終更新:2011年01月27日 17:36