newPiece();
}
void HTetrisBoard::removeFullLines()
{
int numFullLines = 0;
for (int i = HTetrisBoardHeight - 1; i >= 0; --i) {
bool lineIsFull = true;
for (int j = 0; j < HTetrisBoardWidth; ++j) {
if (shapeAt(j, i) == HTetrisPieceShapeNone) {
lineIsFull = false;
break;
}
}
if (lineIsFull) {
++numFullLines;
for (int k = i; k < HTetrisBoardHeight - 1; ++k) {
for (int j = 0; j < HTetrisBoardWidth; ++j)
shapeAt(j, k) = shapeAt(j, k + 1);
}
for (int j = 0; j < HTetrisBoardWidth; ++j)
shapeAt(j, HTetrisBoardHeight - 1) = HTetrisPieceShapeNone;
}
}
if (numFullLines > 0) {
switch(numFullLines){
case 1:
exp += 1;
score += 10;
break;
case 2:
exp += 2;
score += 20;
break;
case 3:
exp += 3;
score += 30;
break;
case 4:
exp += 5;
score += 50;
break;
}
emit scoreChanged(score);
timer.start(500, this);
isWaitingAfterLine = true;
curPiece.setShape(HTetrisPieceShapeNone);
update();
}
}
void HTetrisBoard::newPiece()
热门文档