アットウィキロゴ

インv-6

import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
class pro extends Frame implements Runnable{

Frame f;
Thread th;
int x[]=new int[16];
int y[]=new int[16];
int z[]=new int[16];
int mx[]=new int[200];
int my[]=new int[200];
int mz[]=new int[200];
int m,n,s;
int mode,t;
int xs,ys,maxx,minx,miny;
int dx;
int gun;
int dg;
int no;
int h;
int score;

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

pro() {
addWindowListener(new stopwin());
s=1;
for(m=8;m<11;m++){
for(n=3;n<8;n++){
x[s]=n;
y[s]=m;
z[s]=1;
s=s+1;
}
}

for (no=1;no<200;no++){
mx[no]=0;
my[no]=0;
mz[no]=0;
}

mode=0;
t=0;
dx=1;
gun=5;
th=new Thread(this);
th.start();
}

class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}

public void paint( Graphics g ) {
g.setColor(Color.yellow);
g.fillRect(0,0,700,700);

g.setColor(Color.blue);
for (s=1;s<16;s++){
if (z[s]==1)g.fillRect(50*x[s]+100,600-50*y[s],5,5);
}

g.setColor(Color.red);
for (no=1;no<t;no++){
if (mz[no]==1)g.fillRect(50*mx[no]+100,600-50*my[no],5,5);
}

g.setColor(Color.red);
g.fillRect(50*gun+100,600,10,10);
}

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

public void run() {

while(mode<10){
maxx=0;
for (s=1;s<16;s++){
xs=x[s];
if (z[s]==0)xs=0;
if(xs>maxx)maxx=x[s];
}

minx=999;
for (s=1;s<16;s++){
xs=x[s];
if (z[s]==0)xs=999;
if(xs<minx)minx=x[s];
}

miny=999;
for (s=1;s<16;s++){
ys=y[s];
if (z[s]==0)ys=999;
if(ys<miny)miny=y[s];
}

for (s=1;s<16;s++){
if (maxx>9)y[s]=y[s]-1;
if (maxx>9)dx=-1;
}

for (s=1;s<16;s++){
if (minx<1)y[s]=y[s]-1;
if (minx<1)dx=1;
}

for (s=1;s<16;s++){
x[s]=x[s]+dx;
}

dg=1;
if (Math.random()>0.5)dg=-1;
gun=gun+dg;
if (gun<1)gun=0;
if (gun>9)gun=10;

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

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

for (no=1;no<t;no++){
for (s=1;s<16;s++){
h=0;
if (mx[no]==x[s])h=h+1;
if (my[no]==y[s])h=h+1;
if (z[s]==1)h=h+1;
if (mz[no]==1)h=h+1;
if (h==4)z[s]=0;
if (h==4)mz[no]=0;
}
}

score=0;
for (s=1;s<16;s++){
if (z[s]==0)score=score+1;
}

if (score>14)mode=200;
if (miny<1)mode=100;
if (t>100)mode=100;
t=t+1;
repaint();
try{th.sleep(100);} catch(InterruptedException e) { }
}





}
}
最終更新:2010年10月05日 04:19