六子冲棋01.docx
- 文档编号:3040591
- 上传时间:2022-11-17
- 格式:DOCX
- 页数:29
- 大小:20.81KB
六子冲棋01.docx
《六子冲棋01.docx》由会员分享,可在线阅读,更多相关《六子冲棋01.docx(29页珍藏版)》请在冰豆网上搜索。
六子冲棋01
packagezlvchess;
importjava.awt.Color;
importjava.awt.Font;
importjava.awt.Graphics;
importjava.awt.Graphics2D;
importjava.awt.Point;
importjava.awt.event.MouseEvent;
importjava.awt.event.MouseListener;
importjava.io.PrintStream;
importjavax.swing.JFrame;
publicclassLv13extendsJFrame
implementsMouseListener
{
privatestaticfinallongserialVersionUID=1L;
intstate;
intxx;
intyy;
int[][]position;
inta;
intc;
intb;
intx;
inty;
intr;
intgreennum;
intgreeneat;
intorangenum;
intorangeeat;
booleanGREEN;
booleanG;
inta1;
intb1;
intc1;
intd1;
Fontfont;
Strings;
Strings1;
Strings2;
Strings4;
Strings5;
Strings6;
Strings0;
Strings3;
Strings7;
Stringssssssssss;
Stringssssssss;
Stringsssssssss;
publicLv13()
{
this.state=1;
this.position=newint[13][13];
this.position[2][2]=1;
this.position[4][2]=1;
this.position[2][6]=1;
this.position[4][6]=1;
this.position[0][4]=1;
this.position[2][4]=1;
this.position[4][4]=1;
this.position[6][4]=1;
this.position[0][0]=2;
this.position[2][0]=2;
this.position[4][0]=2;
this.position[6][0]=2;
this.position[0][2]=2;
this.position[6][2]=2;
this.position[0][8]=3;
this.position[2][8]=3;
this.position[4][8]=3;
this.position[6][8]=3;
this.position[0][6]=3;
this.position[6][6]=3;
this.a=100;this.c=100;this.b=100;
this.r=(this.c/4);
this.greennum=0;
this.greeneat=6;
this.orangenum=0;
this.orangeeat=6;
this.GREEN=true;
this.font=newFont("华文行楷",1,25);
this.s="绿方先走!
请绿方点击自己棋子!
";
this.s1="绿方走动步数:
";
this.s2="黄方走动步数:
";
this.s4="绿方的棋子数目:
";
this.s5="黄方的棋子数目:
";
this.s6="温馨提示:
玩家执绿棋!
";
this.s0="游戏开始!
";
this.s3=null;
this.s7="playerorcomputer:
from_,_to_,_";
this.ssssssssss="以下是一些判断!
";
this.ssssssss="以下电脑评分走棋";
this.sssssssss="以下电脑按评分走棋";
setLayout(null);
setTitle("【单机版】六子冲棋1.0版作者:
康子QQ858494658微信号:
hangkanghua公众号:
kzgzsz");
addMouseListener(this);
setSize(1000,700);
setLocationRelativeTo(null);
setDefaultCloseOperation(3);
setResizable(true);
setVisible(true);
}
publicstaticvoidmain(String[]args)
{
newLv13();
}
publicvoidpaint(Graphicsg)
{
super.paintComponents(g);
Graphics2Dg2d=(Graphics2D)g;
g2d.setColor(Color.BLACK);
drawchessboard(g2d,this.a,this.b,this.c);
drawpieces(g2d);
g2d.setColor(Color.BLACK);
g2d.setFont(this.font);
g2d.drawString(this.s,500,250);
g2d.drawString(this.s6,500,200);
g2d.drawString(this.s7,500,320);
g2d.drawString(this.s1+this.greennum,550,400);
g2d.drawString(this.s2+this.orangenum,550,450);
g2d.drawString(this.s4+this.greeneat,550,500);
g2d.drawString(this.s5+this.orangeeat,550,550);
g2d.drawString("state="+this.state,500,150);
g2d.drawString(this.GREEN+""+(this.greennum+this.orangenum),650,150);
g2d.drawString(this.s0,500,100);
if(this.s3!
=null)
g2d.drawString(this.s3,600,100);
}
publicvoiddrawpieces(Graphics2Dg2d)
{
for(inti=0;i<13;i++)
for(intj=0;j<13;j++){
intplecesX=this.a+i*this.c/2;
intplecesY=this.b+j*this.c/2;
if(this.position[i][j]==2)
{
g2d.setColor(Color.GREEN);
g2d.fillOval(plecesX-this.r,plecesY-this.r,2*this.r,2*this.r);
}
if(this.position[i][j]==3){
g2d.setColor(Color.ORANGE);
g2d.fillOval(plecesX-this.r,plecesY-this.r,2*this.r,2*this.r);
}
}
}
publicvoiddrawchessboard(Graphics2Dg2d,inta,intb,intc)
{
for(inti=0;i<=3;i++)
for(intj=0;j<=4;j++){
g2d.drawLine(a+i*c,b+j*c,a+(3-i)*c,b+j*c);
g2d.drawLine(a+i*c,b+j*c,a+i*c,b+(4-j)*c);
}
}
publicbooleanisnext(intxx,intyy,intx,inty)
{
booleanb=false;
if((x==xx)&&(y!
=yy))
{
if((xx==x)&&(Math.abs(y-yy)==2)){
b=true;
}
else
b=false;
}elseif((y==yy)&&(x!
=xx))
{
if((yy==y)&&(Math.abs(x-xx)==2)){
b=true;
}
else
b=false;
}
elseb=false;
returnb;
}
publicvoidgoodwei(intx,inty)
{
if((this.position[4][y]!
=1)&&(this.position[4][y]==this.position[6][y])&&
(this.position[0][y]==1)&&(this.position[2][y]!
=this.position[4][y])&&
(this.position[2][y]!
=1)){
if(this.position[2][y]!
=this.position[x][y])
{
this.position[2][y]=1;
if(!
this.GREEN)
this.greeneat-=1;
else{
this.orangeeat-=1;
}
}
}
elseif((this.position[2][y]!
=1)&&(this.position[2][y]==this.position[4][y])&&
(this.position[0][y]!
=this.position[2][y])&&(this.position[6][y]==1)&&
(this.position[0][y]!
=1)){
if(this.position[0][y]!
=this.position[x][y])
{
this.position[0][y]=1;
if(!
this.GREEN)
this.greeneat-=1;
else{
this.orangeeat-=1;
}
}
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 六子冲棋 01
![提示](https://static.bdocx.com/images/bang_tan.gif)