我正在製作一個國際象棋遊戲,用OpenGL渲染。C++/OpenGL國際象棋遊戲程序設計建議
我不是在找人告訴我所有的答案,我想要自己的代碼出來,但指出我正確的概念是我真正需要的。在這一點上,我不確定從哪裏開始。這裏是我已經想通了:
枚舉,TurnState
,具有以下值:
playerOneTurn
playerTwoTurn
Stopped
枚舉,GameState
,與以下值:
playerOneCheck
playerTwoCheck
playerOnecCheckMate
PlayerTwoCheckMate
InitializingGame
Tie
NormalPlay
抽象類,Player
,和一個子類,Computer
。
類,ChessGame
,具有以下字段:
Player p1, p2
TurnState turnState
GameState gameState
類,Move
,具有以下字段:
*Piece
Location origin
Location destination
類,Location
,具有以下字段:
row
col
*ChessBoard
A class,ChessBoard
,使用一種方法isValid
,它需要Move
並檢查移動是否有效。
一個抽象類,ChessPieces
,用下面的方法:
GetValue() // returns an int value of the piece (for scoring)
GetPosition() // returns the current position of a piece
getIsSelected() // returns a boolean, true if selected, false if unselected
move() // moves the piece in a way dependent upon what piece
而下面的子類:
Pawn
Rook
Queen
King
Knight
堆棧溢出的格式,減價,搞砸了原來的格式。我已經將其編輯爲更具可讀性,但您可能需要進一步編輯它。 – icktoofay