我正在进行步步高游戏,我使用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]
答案 0 :(得分:0)
我假设您还有E
代表空方格。然后你要做的就是(假设新的方块已经是空的):
stoneCounts[2][3] = stoneCounts[0][1];
stoneCounts[0][1] = E;
换句话说,只需将旧方块的状态复制到新方块(并记住以某种方式清除旧方块的状态。)