资源简介
java写的网络围棋程序
代码片段和文件信息
import java.awt.*;
import java.util.*;
//import javax.swing.*;
//import java.awt.image.*;
public class Go extends Panel
{
int whichStep;
Hashtable myHash;
Point pointNow;//当前的点
Point STARTPOINT;
int INTERVAL;
Vector vec;
Point robPoint;
Point mousePoint;
boolean errorFlag;
//构建器
public Go()
{
super();
pointNow=new Point(10001000);//把初始红点画在外面
errorFlag=false;//行棋错误标志
whichStep=0;
STARTPOINT=new Point(2020);
INTERVAL=20;
myHash=new Hashtable();
robPoint=null;//打劫点
mousePoint=new Point();//开辟鼠标点内存
vec=new Vector();//存放校验的子
this.initMyHash(STARTPOINTINTERVAL);
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
//初始化hashtable
void initMyHash(Point startPointint interval)
{
One one;
Point key;//逻辑点标志
int ij;
for(i=1;i<=19;i++)
for(j=1;j<=19;j++)
{
key=new Point(ij);
one=new One();
one.posX=startPoint.x+(i-1)*interval;
one.posY=startPoint.y+(j-1)*interval;
//获取相邻点
one.pointAround[0]=new Point(ij-1);//上
one.pointAround[1]=new Point(ij+1);//下
one.pointAround[2]=new Point(i-1j);//左
one.pointAround[3]=new Point(i+1j);//右
if(i==1)one.pointAround[2]=one.OUT;
if(i==19)one.pointAround[3]=one.OUT;
if(j==1)one.pointAround[0]=one.OUT;
if(j==19)one.pointAround[1]=one.OUT;
myHash.put(keyone);
}
}
//更新盘面
public void paint(Graphics g)
{
Point startPoint=STARTPOINT;
int interval=INTERVAL;
this.paintChessboard(gstartPointinterval);
this.paintChessman(gstartPointinterval);
}
//画棋盘
void paintChessboard(Graphics gPoint startPointint interval)
{
int pX=startPoint.x;
int pY=startPoint.y;
int LINELENGTH=interval*18;
int i;
for(i=0;i<19;i++)
{
g.drawLine(pX+i*intervalpYpX+i*intervalpY+LINELENGTH);
g.drawLine(pXpY+i*intervalpX+LINELENGTHpY+i*interval);
}
g.fillOval(pX+interval*3-3pY+interval*3-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*9-3pY+interval*3-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*15-3pY+interval*3-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*3-3pY+interval*9-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*9-3pY+interval*9-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*15-3pY+interval*9-3(int)(interval-14)(int)(interval-14));
g.fillOval(pX+interval*3-3pY+interval*15-3(int)(interval-14)(int)(interval-14));
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9456 2001-07-09 08:18 weiqi\Go.java
文件 201 2001-07-09 08:18 weiqi\Goap
文件 750 2001-07-09 08:18 weiqi\Listen.java
文件 17710 2001-07-09 08:18 weiqi\MainWindow.java
文件 262 2001-07-09 08:18 weiqi\One.java
文件 5591 2001-07-09 08:19 weiqi\Go.class
文件 311 2001-07-09 08:19 weiqi\Goap
文件 992 2001-07-09 08:19 weiqi\Listen.class
文件 474 2001-07-09 08:19 weiqi\MainWindow$1.class
文件 474 2001-07-09 08:19 weiqi\MainWindow$2.class
文件 505 2001-07-09 08:19 weiqi\MainWindow$3.class
文件 505 2001-07-09 08:19 weiqi\MainWindow$4.class
文件 474 2001-07-09 08:19 weiqi\MainWindow$5.class
文件 472 2001-07-09 08:19 weiqi\MainWindow$6.class
文件 473 2001-07-09 08:19 weiqi\MainWindow$7.class
文件 12261 2001-07-09 08:19 weiqi\MainWindow.class
文件 612 2001-07-09 08:19 weiqi\One.class
目录 0 2001-10-24 17:14 weiqi\
评论
共有 条评论