我正在制作一个用 OpenGL 渲染的国际象棋游戏。
我不是在找人来告诉我所有的答案,我想自己弄清楚代码,但我真正需要的是指出正确的概念。在这一点上,我不知道从哪里开始。这是我发现的:
一个枚举,TurnState,具有以下值:
playerOneTurnplayerTwoTurnStopped
一个枚举,GameState,具有以下值:
playerOneCheckplayerTwoCheckplayerOnecCheckMatePlayerTwoCheckMateInitializingGameTieNormalPlay
一个抽象类 ,Player和一个子类 , Computer。
具有以下字段的类ChessGame:
Player p1, p2
TurnState turnState
GameState gameState
具有以下字段的类Move:
*Piece
Location origin
Location destination
具有以下字段的类Location:
row
col
*ChessBoard
一个类, ChessBoard, 有一个方法, isValid, 它接受 aMove并检查移动是否有效。
具有以下方法的抽象类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
以及以下子类:
PawnRookQueenKingKnight