case HTetrisPieceRotate90:
for(int i=0; i<4; i++){
int tmp = x(i);
setX(i,-y(i));
setY(i, tmp);
}
break;
case HTetrisPieceRotate180:
for(int i=0; i<4; i++){
setX(i,-x(i));
setY(i, -y(i));
}
break;
case HTetrisPieceRotate270:
for(int i=0; i<4; i++){
int tmp = x(i);
setX(i,y(i));
setY(i, -tmp);
}
break;
default:
break;
}
}
HTetrisPiece HTetrisPiece::pieceFromRotatedLeft()const
{
if (pieceShape == HTetrisPieceShapeO)
return *this;
HTetrisPiece result;
result.pieceShape = pieceShape;
for (int i = 0; i < 4; ++i) {
result.setX(i, y(i));
result.setY(i, -x(i));
}
return result;
}
HTetrisPiece HTetrisPiece::pieceFromRotatedRight()const
{
if (pieceShape == HTetrisPieceShapeO)
return *this;
HTetrisPiece result;
result.pieceShape = pieceShape;
for (int i = 0; i < 4; ++i) {
result.setX(i, -y(i));
result.setY(i, x(i));
}
return result;
}
/*
*Filename: HTetrisBoard.h
*Author: Hale Chan <halechan@qq.com>
*Date: 2011-11-24
*/
热门文档