void roomList::setWaiting(string waitingString) { for(int i=0; i<waiting.size(); ++i) { waiting.at(i) = 0; } int currentType = 0; int total = 0; for(int i=0; i<waitingString.length(); ++i) { if(waitingString.at(i) >= 'A') { currentType += total; total = 0; waiting.at(gameType(currentType)) = waitingString.at(i) - 'A'; } else if(waitingString.at(i) >= '0' && waitingString.at(i) <= '9') { if(total != 0) { total *= 10; } total += waitingString.at(i) - '0'; } } }
GenericTetris::GenericTetris() { for(int i = 0 ; i < Height ; i++) for(int j = 0 ; j < Width ; j++) board[j][i] = 0; currentLine = -1; // -1 if no falling piece. currentPos = 0; showNext = 0; // FALSE score = 0; level = 1; nClearLines = Height; nextPiece.setRandomType(gameType()); }
void GenericTetris::newPiece() { currentPiece = nextPiece; if (showNext) eraseNextPiece(); nextPiece.setRandomType(gameType()); if (showNext) showNextPiece(); currentLine = Height - 1 + currentPiece.getMinY(); currentPos = Width/2 + 1; if (!canMoveTo(currentPos,currentLine)) { currentLine = -1; gameOver(); } else { showPiece(); } }