{{0, 0}, {0, 0}, {0, 0}, {0, 0}},
{{0, -1}, {0, 0}, {0, 1}, {0, 2}},
{{-1, 0}, {0, 0}, {1, 0}, {0, 1}},
{{0, -1}, {0, 0}, {0, 1}, {-1, 1}},
{{0, -1}, {0, 0}, {0, 1}, {1, 1}},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}},
{{-1, -1}, {0, -1}, {0, 0}, {1, 0}},
{{1, -1}, {0, -1}, {0, 0}, {-1, 0}}
};
void HTetrisPiece::setRandomShape()
{
setShape((HTetrisPieceShape)(qrand() % 7 + 1));
}
void HTetrisPiece::setShape(HTetrisPieceShape shape)
{
for (int i=0; i<4; i++){
coords[i][0] = coordsTable[shape][i][0];
coords[i][1] = coordsTable[shape][i][1];
}
pieceShape = shape;
}
int HTetrisPiece::minX()const
{
int min = coords[0][0];
for (int i = 1; i < 4; ++i)
min = qMin(min, coords[i][0]);
return min;
}
int HTetrisPiece::maxX()const
{
int max = coords[0][0];
for (int i = 1; i < 4; ++i)
max = qMax(max, coords[i][0]);
return max;
}
int HTetrisPiece::minY()const
{
int min = coords[0][1];
for (int i = 1; i < 4; ++i)
min = qMin(min, coords[i][1]);
return min;
}
int HTetrisPiece::maxY()const
{
int max = coords[0][1];
for (int i = 1; i < 4; ++i)
max = qMax(max, coords[i][1]);
return max;
}
void HTetrisPiece::setRotate(HTetrisPieceRotate rotate)
{
switch(rotate){
热门文档