WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章J2ME技术程序开发象棋手机游戏的源代码

象棋手机游戏的源代码
作者:dlut_608_#4  来源:本站整理  发布时间:2005-11-24 17:22:42
123;
if(point[guard2][guard1]<=16)
{
g.setColor(255,255,0);
g.fillArc(x-chessR+guard1*cellWidth,x-chessR+guard2*cellWidth,2*chessR,2*chessR,0,360);
g.setColor(0x00000000);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
g.drawString(word[guard2][guard1],x+guard1*cellWidth,x+chessR+guard2*cellWidth,Graphics.HCENTER|Graphics.BOTTOM);
}
}
if(g2%2==0)
{
if(point[guard2][guard1]>16)
{
g.setColor(0,255,0);
g.fillArc(x-chessR+guard1*cellWidth,x-chessR+guard2*cellWidth,2*chessR,2*chessR,0,360);
g.setColor(0x00000000);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
g.drawString(word[guard2][guard1],x+guard1*cellWidth,x+chessR+guard2*cellWidth,Graphics.HCENTER|Graphics.BOTTOM);
}
}
}

}
protected void whoIsGoing(Graphics g)//判断该谁走了
{
checkWin();
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
if(isRedWin!=0)
{
if(g2%2==1){
g.setColor(255,0,0);
g.drawString("该红方走了",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);
}
}
else{ g.setColor(255,255,255);
g.drawString("白方胜利",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);}
if(isWhiteWin!=0)
{
if(g2%2==0){
g.setColor(255,255,255);
g.drawString("该白方走了",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);
}
}
else{ g.setColor(255,0,0);
g.drawString("红方胜利",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);}
}
protected void checkWin()//判断输赢
{ isRedWin=0;isWhiteWin=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){if(point[0+i][3+j]==5){isRedWin++;}}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){if(point[7+i][3+j]==21){isWhiteWin++;}}
}
}

protected void paintSelected(Graphics g)//画选择框
{
g.setColor(0,0,255);
g.drawRect(x-chessR+selectedX*cellWidth,x-chessR+selectedY*cellWidth,2*chessR,2*chessR);

}

protected void paint(Graphics g)
{
g.setColor(0x00000000);

g.fillRect(0, 0, getWidth(), getHeight());

paintMapa(g);
paintMapb(g);
paintMapc(g);
paintAllChess(g);

if(guard%2==1)
{
chooseChess(g);
}

paintSelected(g);
whoIsGoing(g);
}
protected void changTwoChessNum(int m,int n,int selectedX,int selectedY)//改变两个格子的值
{
g2++;
p=point[selectedY][selectedX];
point[selectedY][selectedX]=point[n][m];
point[n][m]=0;
q=word[selectedY][selectedX];
word[selectedY][selectedX]=word[n][m];
word[n][m]="空";
}
protected void theRuleOfChe(int m,int n,int selectedX,int selectedY)//车的规则
{
g=0;
if(m==selectedX)
{
if(n>selectedY)
{
for(i=1;i {
if(point[selectedY+i][m]!=0){g++;}
}
}
else
{
for(i=1;i {
if(point[n+i][m]!=0){g++;}
}
}
if(g==0){changTwoChessNum(m,n,selectedX,selectedY);}

}
if(n==selectedY)
{
if(m>selectedX)
{
for(i=1;i {
if(point[n][i+selectedX]!=0){g++;}
}
}
else
{
for(i=1;i {
if(point[n][m+i]!=0){g++;}
}
}
if(g==0){changTwoChessNum(m,n,selectedX,selectedY);}

}
}
protected void theRuleOfMa(int m,int n,int selectedX,int selectedY)//马的规则
{
if(n<9){
if(point[n+1][m]==0)
{
if(selectedX-m==1){if(selectedY-n==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n>0){
if(point[n-1][m]==0)
{
if(m-selectedX==1){if(n-selectedY==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n<9){
if(point[n+1][m]==0)
{
if(selectedX-m==-1){if(selectedY-n==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n>0){
if(point[n-1][m]==0)
{
if(m-selectedX==-1){if(n-selectedY==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m<8){
if(point[n][m+1]==0)
{
if(selectedX-m==2){if(selectedY-n==1){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m>0){
if(point[n][m-1]==0)
{
if(m-selectedX==2){if(n-selectedY==1){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m<8){
if(point[n][m+1]==0)
{
if(selected

上一页  [1] [2] [3] [4] [5] [6]  下一页

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码