//囲碁アプレット 制作:ハルーポッター import java.awt.*; import java.applet.*; import java.awt.event.*; /********************************************************************************/ /* */ /* 碁盤クラス */ /* */ /********************************************************************************/ class Go{ int color;//色(0=空白,1=黒,2=白) boolean visit;//訪問チェックフラグ Go(){ color=0; visit=false; } } /********************************************************************************/ /* */ /* 囲碁クラス */ /* */ /********************************************************************************/ public class Igo extends Applet implements Runnable,MouseListener,MouseMotionListener{ //定数 final int SIZE=19;//路 final int IMAGE_SIZE=16;//画像サイズ final int START_X=0;//始点(X座標) final int START_Y=0;//始点(Y座標) final int IMAGE_NUM=13;//画像ファイルの数 //一般変数 Dimension d;//領域 Image buffer;//イメージバッファ Graphics bufferg;//バックバッファ Go go[][] = new Go[SIZE][SIZE];//碁盤 int nowcolor;//現在の色 Image IgoBmps[] = new Image[IMAGE_NUM];//画像 Point mousep = new Point();//マウス座標 boolean end_flag;//訪問完了フラグ /********************************************************************************/ /* */ /* 初期化 */ /* */ /********************************************************************************/ public void init(){ int i,j; //いつも通りの初期化 this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));//カーソルの形 d = getSize();//領域取得 this.addMouseListener(this);//マウスイベント受付 this.addMouseMotionListener(this); nowcolor = 1; for(i=0;i=1){ if(go[x][y-1].color == 3-nowcolor){ reset(); flag=remove_check(x,y-1); if(flag)visit(x,y-1); } } if(y=1){ if(go[x-1][y].color == 3-nowcolor){ reset(); flag=remove_check(x-1,y); if(flag)visit(x-1,y); } } if(x=1){ if(!go[x-1][y].visit)remove_check(x-1,y); } } if(!end_flag){ if(x=1){ if(!go[x][y-1].visit)remove_check(x,y-1); } } if(!end_flag){ if(y=1){ if(go[i][j-1].color == 3-nowcolor)visit(i,j-1); } if(i>=1){ if(go[i-1][j].color == 3-nowcolor)visit(i-1,j); } } /********************************************************************************/ /* */ /* リセット */ /* */ /********************************************************************************/ public void reset(){ int i,j; for(i=0;i