我正在制作一个国际象棋游戏,用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