TetrisMy#13
Conversation
| Figure::Figure() {} | ||
|
|
||
| void Figure::generateFigure(){ | ||
| QVector<QVector<QVector<int>>> arrayOfFigures; |
There was a problem hiding this comment.
У вас тут вектора, что уже конфликтует с названием array. Обычно мы называем контейнеры просто во множественном числе того, что в нем храним. В вашем случае просто figures будет достаточно.
| arrayOfFigures.append( { {0, 0, 1, 0}, {0, 0, 1, 0}, {0, 1, 1, 0}, {0, 0, 0, 0} } ); | ||
| arrayOfFigures.append( { {0, 1, 1, 0}, {0, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} } ); | ||
| srand(time(NULL)); | ||
| int type = rand() % arrayOfFigures.size(); |
There was a problem hiding this comment.
Тип в данном случае как-то не очень подходит, по сути у всех фигур один тип. Можно назвать как Индекс, РандомныйИндекс, ИндексФигуры или производные этих вариантов.
| int type = rand() % arrayOfFigures.size(); | ||
| figure_ = arrayOfFigures[type]; | ||
| } | ||
| int Figure::getXPoints() const{ |
There was a problem hiding this comment.
Пустая строка между методами. Пробел перед {
|
|
||
| Figure::Figure() {} | ||
|
|
||
| void Figure::generateFigure(){ |
| return figure_.size(); | ||
| } | ||
|
|
||
| int Figure::getYPoints() const{ |
| }; | ||
| } | ||
|
|
||
| void GameField::startNewGame(){ |
|
|
||
| void GameField::clearLines() { | ||
| for (int i = 0; i <= gameField_.size( )- 1; i++) { | ||
| if (std::all_of(gameField_[i].begin(), gameField_[i].end(), [](int val) { return val == 1; } ) ) { |
There was a problem hiding this comment.
Между обычными скобками (()) пробелы не нужны.
| void RowsNumberChanged(); | ||
| void ColumnsNumberChanged(); | ||
| void InitialisationStarted(); |
There was a problem hiding this comment.
Раз оформляете методы с маленькой буквы, то приведите все, что связано с Q_PROPERTY в соответствующий вид.
| void paintEvent(QPaintEvent *event); | ||
| void keyPressEvent(QKeyEvent *event); |
There was a problem hiding this comment.
Не стоит превращать методы в слоты, вынесите paintEvent и keyPressEvent вне слотов.
| } | ||
|
|
||
| void GameField::clearLines() { | ||
| for (int i = 0; i <= gameField_.size( )- 1; i++) { |
There was a problem hiding this comment.
gameField_.size( )- 1 -> gameField_.size() - 1
hBuzzy
left a comment
There was a problem hiding this comment.
Доп. задание принято.
Обратите внимание на замечания. В целом, можете не исправлять, их не так много.
| currentYPosition_++; | ||
| emit moveFigure(); | ||
| }else { | ||
| }else { |
|
|
||
| void GameField::moveFigureRight() { | ||
| if(!isCollision(currentFigure_, 1, 0)) { | ||
| if(!isCollision(currentFigure_, 1, 0)) { |
| QVector<QVector<int>> gameField = gameField_; | ||
|
|
||
| painter.fillRect(0, 0, gameField[0].size()*blockSize, gameField.size()*blockSize, Qt::white); | ||
| painter->fillRect(0, 0, gameField[0].size()*blockSize_, gameField.size()*blockSize_, Qt::white); |
There was a problem hiding this comment.
Пробелы вокруг оператора умножения.
| emit moveFigure(); | ||
| if(isCollision(currentFigure_, 0, 0)){ | ||
| startNewGame(); | ||
| if(isCollision(currentFigure_, 0, 0)) { |
No description provided.