// // Game1 2002/02/10 by ONOZATO Takehisa // // 石の入れ替え(蛙跳びゲーム) // // // import java.awt.*; import java.applet.*; import java.awt.event.*; public class Game1 extends Applet implements MouseListener,ItemListener,ActionListener{ Image ofs; Graphics ofsGrf; //オフスクリーン int ofsWidth=560; int ofsHeight=160; Color ofsBG=new Color(255,239,223); //背景色 Choice cho; //選択メニュー int choLeft=40; int choTop=20; int choWidth=80; int choHeight=25; String choList[]={" n = 1 "," n = 2 "," n = 3 "," n = 4 "," n = 5 "}; //選択項目 int choIndex; Button btn; //ボタン int btnLeft=150; int btnTop=20; int btnWidth=60; int btnHeight=20; String btnCaption="reset"; int LWidth=4; //セルの枠線 int CellLeft=40; int CellTop=80; //セル int CellWidth=40; int CellHeight=40; int nStone; int nCell; //各石の個数,セルの個数 int step; //手数 int CellState[]=new int[12]; //セルの状態 0:空 1:赤 2:白 int emptyCell; //空のセルの番号 public void init() { choIndex=0; //初期値 nStone=choIndex+1; nCell=2*nStone+1; step=0; emptyCell=nStone+1; //初期状態設定 CellState[emptyCell]=0; //中央は空 for(int i=1; i<=nStone; i++){ CellState[i]=1; CellState[nCell+1-i]=2; } ofs=createImage(ofsWidth,ofsHeight); ofsGrf=ofs.getGraphics(); cho=new Choice(); //選択メニュー for(int i=0; iCellTop && y=1 && j<=nCell && (k==1 || k==2)){ CellState[emptyCell]=CellState[j]; //セル状態の書き換え CellState[j]=0; emptyCell=j; step=step+1; repaint(); } } } public void mousePressed(MouseEvent e){} //記述しておく必要あり public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} }