我正在制作一个国际象棋引擎并使用这个代码:
#pragma once
#include "SFML\Graphics.hpp"
#include "Grid.h"
enum PieceType { //place gamePieces into Grid not field, cus grid is already in field
W_BISHOP,
W_PAWN,
W_KING,
W_QUEEN,
W_ROOK,
W_KNIGHT,
B_BISHOP,
B_PAWN,
B_KING,
B_QUEEN,
B_ROOK,
B_KNIGHT
};
class GamePieces //TODO PUT TEAM IN GRID, ACCESS GAME PIECES IN GRID TO MOVE THEM
{
public:
GamePieces(){}
GamePieces(PieceType& type, Coords& position) : m_type(type),m_position(position) {
switch (type) {
case W_BISHOP:
m_gamePiece.loadFromFile("w_bishop");
m_gamePieceSprite.setTexture(m_gamePiece);
break;
//REST OF CASES OF PIECETYPE ARE PRETTY MUCH THE SAME
}
~GamePieces(); …Run Code Online (Sandbox Code Playgroud)