本文整理汇总了C++中Piece::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Piece::Draw方法的具体用法?C++ Piece::Draw怎么用?C++ Piece::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piece
的用法示例。
在下文中一共展示了Piece::Draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestRook
void ChessBoard::TestRook() {
Piece *p;
bool v;
// Initialize Rook
CleanBoard();
// Put only 2 pieces to test
string origin = "b7";
Rook *rk= new Rook(1, origin, board);
board[1][1]=rk;
Pawn *pw1= new Pawn(2, "a3", board);
board[5][0]=pw1;
Pawn *pw2= new Pawn(1, "h4", board);
board[4][7]=pw2;
Draw();
// Testing movements
cout<< "Putting a piece on the chessboard at "<< "b7"<<"\n";
p= GetPiece("b7");
if (p!=NULL) {
p->Draw();
cout<<"\nplayer: "<< p->player<<endl;
}
else cout<<"null";
string dest="e4";
cout<<"trying to move rook horizontally to "<<dest<<" \n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="a7";
cout<<"trying to move rook vertically to "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="c4";
cout<<"trying to make an invalid rook move to "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "a3";
cout<<"trying to capture a piece at "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "h4";
cout<<"trying to capture a piece from the same player at "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
}
示例2: TestQueen
void ChessBoard::TestQueen() {
Piece *p;
bool v;
// Initialize Queen
CleanBoard();
// Put only 2 pieces to test
string origin = "b7";
Queen *rk= new Queen(1, origin, board);
board[1][1]=rk;
Pawn *pw1= new Pawn(2, "a6", board);
board[2][0]=pw1;
Pawn *pw2= new Pawn(1, "c6", board);
board[2][3]=pw2;
Draw();
// Testing movements
cout<< "Putting a piece on the chessboard at "<< "b7"<<"\n";
p= GetPiece("b7");
if (p!=NULL) {
p->Draw();
cout<<"\nplayer: "<< p->player<<endl;
}
else cout<<"null";
string dest="b6";
cout<<"trying to move one vertically "<<dest<<" \n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="b1";
cout<<"trying to move vertically to "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="a6";
cout<<"trying to capture "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "c4";
cout<<"trying to do an invalid move "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "h1";
cout<<"trying to capture "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
}
示例3: TestKnight
void ChessBoard::TestKnight() {
Piece *p;
bool v;
// Initialize Bishop
CleanBoard();
// Put only 2 pieces to test
string origin = "e5";
Knight *rk= new Knight(1, origin, board);
board[3][4]=rk;
Pawn *pw1= new Pawn(1, "c4", board);
board[4][2]=pw1;
Pawn *pw2= new Pawn(1, "c6", board);
board[2][3]=pw2;
Draw();
// Testing movements
cout<< "Putting a piece on the chessboard at "<< "a4"<<"\n";
p= GetPiece("e5");
if (p!=NULL) {
p->Draw();
cout<<"\nplayer: "<< p->player<<endl;
}
else cout<<"null";
string dest="g4";
cout<<"trying to move to "<<dest<<" \n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="c6";
cout<<"trying to move to "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest="c4";
cout<<"trying to capture "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "h1";
cout<<"trying to do an invalid move "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
dest= "h1";
cout<<"trying to capture "<<dest<<"\n";
v= Validate(p, dest);
cout << (v ? "\tvalid\n" : "\tinvalid\n");
}
示例4: Draw
void NextPiece::Draw(Bitmap &canvas) {
if (piece) {
canvas.Clear(skin->c_face);
piece->Draw(canvas, 0, 0);
}
}