Esempio n. 1
0
int main()
{
	#ifdef _DEBUG
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	_CrtDumpMemoryLeaks();
	#endif

        
	CChessKing King(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(7, 4));
	CChessKnight Knight(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(2, 1));

	CChessKing King2(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(0, 0));
	CChessKnight Knight2(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(2, 1));
	CChessKnight Knight3(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(99, 19));

	CChessBaseFigure *pFigures[32];
	pFigures[0] = &King;
	pFigures[1] = &Knight;

	CChessKing WKing(CChessBaseFigure::FIGURE_WHITE, DirectX::XMINT2(0, 3));
        
        
	/*
	// check
	CChessKing BKing(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(4, 7));
	CChessRook BRook(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(2, 6));

	CChessKing WKing(CChessBaseFigure::FIGURE_WHITE, DirectX::XMINT2(2, 2));
	*/

	/*
	// checkmate
	CChessKing BKing(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(3, 2));
	CChessRook BRook(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(6, 0));

	CChessKing WKing(CChessBaseFigure::FIGURE_WHITE, DirectX::XMINT2(3, 0));
	*/

	/*
	// stalemate
	CChessKing BKing(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(2, 3));
	CChessQuenn BQuenn(CChessBaseFigure::FIGURE_BLACK, DirectX::XMINT2(2, 1));

	CChessKing WKing(CChessBaseFigure::FIGURE_WHITE, DirectX::XMINT2(0, 2));
	*/

	CChessBoard::GetInstance()->Draw();

	printf(CChessBoard::GetInstance()->GetState(&WKing).c_str());

	CChessBoard::GetInstance()->Clear();
	ClearFiguresData();

	_getch();
	return 0;
}
Esempio n. 2
0
void Filling(Mat board, const Coor &size, Figures &figures)
{
	for (Figures::iterator it = figures.begin(); it != figures.end(); it++)
		board[it->ln][it->col] = it->val;
	for (Figures::iterator it = figures.begin(); it != figures.end(); it++)
	{
		if (it->val == -1)
			Knight(board, size, *it);
		else if (it->val == -2)
			Bishop(board, size, *it);
		else
			Rook(board, size, *it);
	}
}
Esempio n. 3
0
void CChessGUI::DrawPiece(CPiece piece)
{
	gl::Piece pieceType = decodePiece(piece);


	switch(pieceType)
	{
	case gl::Rook:
		Rook(piece);
		break;
	case gl::Biship:
		Biship(piece);
		break;
	case gl::Knight:
		Knight(piece);
		break;
	case gl::King:
		King(piece);
		break;
	case gl::Queen:
		Queen(piece);
		break;
	case gl::Pawn:
		Pawn(piece);
		break;

	};
	
	//for now, just draw squares
	/*
	GLfloat glX1 = tileNumber.x*.09375+.125+.03;
	GLfloat glY1 = tileNumber.y*.09375+.125+.03;
	GLfloat glX2 = tileNumber.x*.09375+.125+.09375-.03;
	GLfloat glY2 = tileNumber.y*.09375+.125+.09375-.03;


	glColor3f(200, 10, 0);
	glBegin(GL_QUADS);
		glVertex2f(glX1,glY1);
		glVertex2f(glX2,glY1);
		glVertex2f(glX2,glY2);
		glVertex2f(glX1,glY2);
	glEnd();*/
}
Esempio n. 4
0
void Play() {
    CurrentBoardPosition=-1;
    MoveClassification=0;
    MoveAlreadyMadeFlag=0;
    Error=0;
    PieceError=0;
    if(MoveCycleNumber==1) {
        WhitePawnEnPassantFlag=0;
        BlackPawnEnPassantFlag=0;
    }

    while(Error==0) {
        PlayInputTranslate();
        Castle();
        Whitepawn();
        ErrorSignal();
        CHECKERROR
        BlackPawn();
        ErrorSignal();
        CHECKERROR
        PawnToQueen();
        Rook();
        ErrorSignal();
        CHECKERROR
        Knight();
        ErrorSignal();
        CHECKERROR
        Bishop();
        ErrorSignal();
        CHECKERROR
        Queen();
        ErrorSignal();
        CHECKERROR
        King();
        ErrorSignal();
        CHECKERROR
        Etc();
        ErrorSignal();
        break;
    }
}