Tetris vakilova#8
Conversation
| #include "tetrisgrid.h" | ||
|
|
||
| class MainWindow : public QMainWindow | ||
| { |
| TetrisGrid *tetrisGrid; | ||
| QPushButton *startButton; | ||
| QPushButton *exitButton; | ||
| QPushButton *helpButton; | ||
| QLabel *scoreLabel; |
There was a problem hiding this comment.
Сначала приватные методы, потом приватные поля
У приватных полей добавляем постфикс "_"
| QLabel *scoreLabel; | ||
| void setupGame(); | ||
| int score_; | ||
| bool gameOverHandled_ = false; |
There was a problem hiding this comment.
Переменные типа bool должны задавать вопрос, на который мы можем строго ответить либо "Да", либо "Нет". Достигается это при помощи глаголов Is, Have, has и т.д.
| void showHelp(); | ||
|
|
||
| public slots: | ||
| void keyPressEvent(QKeyEvent *event); |
There was a problem hiding this comment.
keyPressEvent - это не слот, а обычный метод, при чем protected
|
|
||
|
|
| for (int j = 0; j < currentShape_[i].size(); ++j) { | ||
| if (currentShape_[i][j] == 1) { | ||
| int gridRow = shapeRow_ + i; | ||
| int gridCol = shapeCol_ + j; |
There was a problem hiding this comment.
То же самое про col. Без сокращений.
| int m_rows_; | ||
| int m_cols_; |
There was a problem hiding this comment.
Исправьте на наш стиль, как и в остальных местах, где остались m_
| QVector<QVector<int>> nextShape_; | ||
| QVector<QVector<int>> m_gridNew_; | ||
| int shapeRow_; | ||
| int shapeCol_; | ||
| int score_; | ||
| int speed_ = 500; | ||
| void drawGrid(QPainter &painter, int cellSize); | ||
| void drawShape(QPainter &painter, int cellSize); | ||
| void generateNewShape(); | ||
| void checkLines(); | ||
| void addCurrentShapeToGridNew(); | ||
| bool isCollision(); | ||
| bool locking_; | ||
| bool shapeLocked_; |
There was a problem hiding this comment.
Не перемешивайте методы и поля. Сначала все методы, потом только все поля.
| bool locking_; | ||
| bool shapeLocked_; |
There was a problem hiding this comment.
Опять же, у bool должен быть вопрос с помощью is, have, has.
| void TetrisGrid::checkLines() { | ||
|
|
||
| for (int row = m_rows_ - 1; row >= 0; --row) { | ||
| bool lineFilled = true; |
| int mRows_; | ||
| int mColumns_; |
| bool isCollision(); | ||
| bool locking_; | ||
| bool shapeLocked_; | ||
| QVector<QVector<int>> mGrid_; |
No description provided.