如何在跳棋游戏中移动一块

时间:2014-11-17 03:52:06

标签: c++ arrays function multidimensional-array

所以,我正在进行一次课堂合作任务,我必须设计一个部分棋盘格。这必须使用控制台窗口完成,并且必须是8x8板。我的朋友正在设计电路板,而我设计的功能是只移动红色部分。他的部分代码将发送给我一个坐标板[行] [列]的矩阵,运动意味着运动= 1是左上角,运动= 2是右上角等等。我有问题了解如何假装要移动。

这是我的代码:

int movered(int movement, int board[][8])
{
    int x;
    int y;
    int piece;

    for (x=0; x == movement; x++)
    {
        x = movement - x;
        for (y=0; y == movement; y++)
        {
            y = movement - y;
        }
    }

    piece = board[x][y];

    board[x][y] = 0;

    DrawBoard(piece, board);

    return piece;
}

1 个答案:

答案 0 :(得分:1)

我对此很陌生,但我对它的看法就是这样的。

int moved(int xPos, int yPos, int moveSelect, int board[][8])
{
        int teamCheck;

        if(board[xPos][yPos] == 1)
                teamCheck = 1;//else = 2

        if(moveSelect == 1) // && xPos >= 0, etc... Moves can't go off board
        {     
                board[xPos][yPos] = 0; //then set new position on board to equal a 1 or 2 depending on team chip is on
                return 1;
        }
        //elseif - do rest of moveSelections

        else
                return 0; //Returning value indicates a success or failure in move
}
相关问题