我已經件陣列中映射出和它打印就好PHP移動檢查件2
$board = array(
array('1','rs','1','rs','1','rs','1','rs'),
array('rs','1','rs','1','rs','1','rs','1'),
array('1','rs','1','rs','1','rs','1','rs'),
array('rs','bs','rs','bs','rs','bs','rs','bs'),
array('bs','rs','bs','rs','bs','rs','bs','rs'),
array('2','bs','2','bs','2','bs','2','bs'),
array('bs','2','bs','2','bs','2','bs','2'),
array('2','bs','2','bs','2','bs','2','bs')
);
1 =黑片
2 =紅色件
RS =紅色正方形
BS =黑色正方形
此代碼解析播放機的輸入:例如,從F2到(0,0)座標
function parseSquareFrom($square) {
if (strlen($square) != 2) {
return FALSE;
}
$coords = array(ord('A') - ord($square[0]), $square[1] - 1);
// Perform bounds-checking.
if ($coords[0] < 0 || $coords[0] > 7 || $coords[1] < 0 || $coords[1] > 7) {
return FALSE;
}
return $coords;
}
我已經重複了同樣的功能的輸入(到玩家想要移動的一塊
我的問題是下一個代碼與功能移到高於一個有效方式
$board[$coords1[0]-1][$coords1[1]+1] = $board[$coords[0]][$coords[1]];
$board[$coords[0]][$coords[1]] = 0;
//eating action
$board[$coords1[0]][$coords1[1]] = 0;
$board[$coords1[0]-2][$coords1[1]+2] = $board[$coords[0]][$coords[1]];
$way = ($_POST['way'] === 'up')? 1:-1;
$way = ($_POST['way'] === 'down')? -1:+1;
//if player is 'up' then the value of $way is 1 so
$board[$x+(-1*$way)][$y+(1*$way)] = $board[$coords[0]][$coords[1]]; // position 2,2 becomes 1,3
//if player is not 'up' then the value of $way is -1 so
$board[$x+(-1*$way)][$y+(1*$way)] = $board[$coords[0]][$coords[1]]; // position 2,2 becomes 3,1
我計劃有一個功能來更新屏幕上的平鋪運動,因此當棋子移動到下一個方塊時它會突出顯示棋子
這是使用序列化到文件來保存開始位置,移動,國王和皇后職位
一樣好。您通過點擊分數下方的箭頭和答案左側的箭頭接受答案。你只能做一個答案。您也可以通過點擊答案旁邊的向上箭頭爲您認爲有用的答案投票。 – 2010-11-19 00:12:29
好吧,我同意我沒有了投票人對這一點我很抱歉,但我已經多次表示感謝,我向大家道歉我激怒了這個問題 – hgbso 2010-11-19 00:32:28
如何將我更新板時,有運動 – hgbso 2010-11-19 19:16:16