freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于j2me的moto手機的五子棋游戲開發(fā)(編輯修改稿)

2025-07-15 16:25 本頁面
 

【文章內(nèi)容簡介】 newGame=true。 empty=10。 canvasW=getWidth()empty。canvasH=getHeight()empty。 chessMapGrid=15。 chesses=new Chesses[chessMapGrid+1][chessMapGrid+1]。 if(canvasWcanvasH){ chessMapLength=canvasHcanvasH%chessMapGrid。 chessMapX=(canvasWchessMapLength)/2+empty/2。 chessMapY=(canvasH%chessMapGrid)/2+empty/2。 } else{ chessMapLength=canvasWcanvasW%chessMapGrid。 chessMapX=(canvasW%chessMapGrid)/2+empty/2。 chessMapY=(canvasHchessMapLength)/2+empty/2。 } chessGridLength=chessMapLength/chessMapGrid。 chessLength=chessGridLength1。 selectedX=selectedY=chessMapGrid/2。 isPlayer1=true。 restartCmd = new Command(重新開始, , 0)。 exitCmd = new Command(退出, , 0)。 addCommand(restartCmd)。 addCommand(exitCmd)。 setCommandListener(this)。 }對游戲的勝負進行判斷,每當下一個棋子的時候,會激活這個方法,進行判斷,在橫、縱、正對角線、反對角線上,如果有連續(xù)的同色的五棋子,則判斷出該色的玩家獲勝。private boolean checkWin(int x,int y,int chessesValue){ int value = chessesValue。 int xx = x。//循環(huán)變量的值 int yy = y。//循環(huán)變量的值 int tempx=x,tempy=y。//存儲當前傳入的值,便于以后從這個點開始進行判斷 /** * 縱向判斷 */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 int count = 0。//用來計算當前某一方的棋子是否夠五個 while(yy=0 amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 yy。 if(yy0)break。 } yy=tempy+1。 while(yychessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 yy++。 if(yychessMapGrid)break。 } if(count == 5) return true。 /** * 橫向判斷 */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 count = 0。//用來計算當前某一方的棋子是否夠五個 while(xx=0 amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx。 if(xx0)break。 } xx=tempx+1。 while(xxchessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx++。 if(xxchessMapGrid)break。 } if(count == 5) return true。 /** * 反向?qū)蔷€ */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 count = 0。//用來計算當前某一方的棋子是否夠五個 while(xx=0 amp。amp。 yychessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx。 yy++。 if(xx0||yychessMapGrid)break。 } xx=tempx+1。 yy=tempy1。 while(yy=0 amp。amp。 xxchessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx++。 yy。 if(yy0||xxchessMapGrid)break。 } if(count == 5) return true。 /** * 正向?qū)蔷€ */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 count = 0。//用來計算當前某一方的棋子是否夠五個 while(xxchessMapGrid amp。amp。 yychessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx++。 yy++。 if(xxchessMapGrid||yychessMapGrid)break。 } xx=tempx1。 yy=tempy1。 while(yy=0 amp。amp。 xx=0 amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx。 yy。 if(xx0||yy0)break。 } if(count == 5) return true。 return false。 }因為該版本的游戲是單機挑戰(zhàn)版的,所以肯定是人和手機對戰(zhàn),如果人下了一個棋子的話,手機就會自動下一個棋子的,下面的方法是電腦根據(jù)人下的棋子進行判斷,如果人下的棋子在橫或者縱或者正對角線或者反對角線上已經(jīng)或者是超過了三個棋子的話,那已經(jīng)構(gòu)成了威脅,需要堵住對方的棋子,否則手機隨機的在棋盤上沒有旗子的地方下一個棋子。程序如下:private int[] checkChesses(int x,int y,int chessesValue){ int[]temp = {0,0}。//存放要走的棋子的位置,temp[0]存放x坐標,temp[1]存放y坐標 int value = chessesValue。 int xx = x。//循環(huán)變量的值 int yy = y。//循環(huán)變量的值 int tempx=x,tempy=y。//存儲當前傳入的值,便于以后從這個點開始進行判斷 int pointX1=0,pointX2=0,pointY1=0,pointY2=0。//用來存放判斷是否已經(jīng)構(gòu)成威脅的位置坐標 /** * 縱向判斷 */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 int count = 0。//用來計算當前某一方的棋子是否夠五個 while(yy=0 amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 yy。 if(yy0)break。 } pointY1=yy。 yy=tempy+1。 while(yychessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 yy++。 if(yychessMapGrid)break。 } pointY2=yy。 if(count = chessesNum amp。amp。 chesses[pointY1][xx]==null amp。amp。 pointY1=0) { temp[0]=xx。 temp[1]=pointY1。 return temp。 }else if(count = chessesNum amp。amp。 chesses[pointY2][xx]==null amp。amp。 pointY2=chessMapGrid) { temp[0]=xx。 temp[1]=pointY2。 return temp。 } /** * 橫向判斷 */ xx=tempx。 yy=tempy。//讓目前的值與傳入的值保持一致 count = 0。//用來計算當前某一方的棋子是否夠五個 while(xx=0 amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx。 if(xx0)break。 } pointX1=xx。 xx=tempx+1。 while(xxchessMapGrid amp。amp。 chesses[yy][xx]!=null amp。amp。 chesses[yy][xx].getChessesValue()==value) { count++。 xx++。 if(xxchessMapGrid)break。 } pointX2=xx。 if(count = chessesNum amp。amp。 chesses[yy][pointX1]==null amp。amp。 pointX1=0) { temp[0]=pointX1。 temp[1]=yy。 return temp。 }else if(count = chessesNum amp。amp。 chesses[yy][pointX2]==null amp。amp。 pointX2=chessMapGrid) { temp[0]=pointX2。 temp[1]=yy。
點擊復制文檔內(nèi)容
畢業(yè)設(shè)計相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1