0

我正在制作西洋双陆棋游戏,并且我使用 2D 数组设置棋盘,如下所示:

stoneCounts[0][0]=stoneCounts[0][1]=stoneCounts[0][2]=stoneCounts[0][3]=stoneCounts[0][4] = W; 
stoneCounts[11][0]=stoneCounts[11][1] = W;
stoneCounts[16][0]=stoneCounts[16][1]=stoneCounts[16][2]= W;
stoneCounts[18][0]=stoneCounts[18][1]=stoneCounts[18][2]=stoneCounts[18][3]=stoneCounts[18][4]=W;
stoneCounts[23][0]=stoneCounts[23][1]=stoneCounts[23][2]=stoneCounts[23][3]=stoneCounts[23][4] =B;
stoneCounts[12][0]=stoneCounts[12][1] = B;
stoneCounts[7][0]=stoneCounts[7][1]=stoneCounts[7][2]=stoneCounts[7][3]=stoneCounts[7][4] =B;
stoneCounts[5][0]=stoneCounts[5][1]=stoneCounts[5][2]=  B;

例如,当玩家移动时,我怎样才能得到。'W' 在stoneCounts[0][1] 移动到stoneCounts[2][3]

4

1 回答 1

0

我假设你也有一个E代表一个空方块的。那么你所要做的就是(假设新广场已经是空的):

 stoneCounts[2][3] = stoneCounts[0][1];
 stoneCounts[0][1] = E;

换句话说,只需将旧方格的状态复制到新方格(并记住以某种方式清除旧方格的状态。)

于 2013-07-12T12:26:08.003 回答