Skip to content

Tetris Okhrimenko v1.0#9

Open
napstergit1 wants to merge 2 commits into
hBuzzy:masterfrom
napstergit1:TetrisOkhrimenko
Open

Tetris Okhrimenko v1.0#9
napstergit1 wants to merge 2 commits into
hBuzzy:masterfrom
napstergit1:TetrisOkhrimenko

Conversation

@napstergit1

Copy link
Copy Markdown

Из проблем на данный момент:

  1. Нужно показывать следующую фигуру
  2. Исправить код стайл
  3. Проверить код на наличие лишнего "мусора"
  4. Корректно обрабатывать проигрыш(сейчас немного не в тот момент срабатывает сигнал)

Из проблем на данный момент:
1) Нужно показывать следующую фигуру
2) Исправить код стайл
3) Проверить код на наличие лишнего  "мусора"
4) Корректно обрабатывать проигрыш(сейчас немного не в тот момент срабатывает сигнал)

@hBuzzy hBuzzy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправить замечания. Убрать ненужные классы, желательно все же выделить фигуры хотя бы в один отдельный класс. Убрать комментарии.

Comment thread gamefield.h Outdated
Comment on lines +30 to +41
void SetColumnNumber(uint newColumnsCount);

void SetFigurePosition(int row, int column);

void spawnNextFigure();
void updateGameGrid();

bool CheckCollision();

bool CheckCollisionMoveLeft();
bool CheckCollisionMoveRight();
bool CheckCollisionRotate();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Либо все методы с большой (как принято в код стиле у нас), либо все с маленькой, придерживаясь стиля QT.

Check - всегда плохое слово, которое почти никогда достаточно не погружает в контекст того, что мы проверяем. Кроме того, методы / переменные / поля типа bool должны задавать вопрос, на который мы можем ответить строго "Да" или "Нет". У вас вопросов нет вообще, только утвердительные формы.

В создании вопроса нам помогают Is, Has, Have и т.д. CheckCollision -> HasCollisions() и т.д.

Comment thread gamefield.h
bool CheckCollisionRotate();

QVector<QVector<int>> GetCurrentFigure();
QVector<QVector<int>> GetRotateCurrentFigure();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rotate - глагол.

Если вы хотите получить поворот, то это rotation. Плюс нужно соблюдать порядок слов. GetCurrentFigureRotation. Технически, конечно, стоит все же выделить ваши наборы фигур в класс фигура хотя бы, чтобы не было такой каши в названиях.

Тогда бы у вас было что-то около: Figure::GetRotation.

Comment thread gamefield.h Outdated

QVector<QVector<int>> currentFigure_;

QVector<QVector<int>> GameGrid_; // Поле с информацией о заполнении поля фигурами

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

С маленькой буквы

Comment thread gamefield.h
Comment on lines +86 to +88
uint currentFigureRow_;
uint currentFigureColumn_;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опять же, выделив все хотя бы в класс фигура, такой каши не будет.

Comment thread gamefield.h Outdated
uint currentFigureRow_;
uint currentFigureColumn_;

QColor colorFigure;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QColor colorFigure; -> QColor figureColor_;

Comment thread tetris.h Outdated

QTimer *timer;
GameField *gamefield;
ModalDialog *modaldialog;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком общее название, уточните.

Comment thread tetris.cpp Outdated
Comment on lines +102 to +105



void Tetris::openEndGameDialog() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не больше одной пустой строки

Comment thread gamefield.cpp Outdated
Comment on lines +359 to +360
for (int i = 0; i < rowsNumber_;i++) {
for (int j = 0; j < columnsNumber_;j++) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пробелы после ; в условиях

Comment thread gamefield.cpp Outdated
if(!isGameOver) {
// Проверка, не касается ли текущая фигура нижней границы поля
if (currentFigureRow_ + currentFigure_.size() < rowsNumber_) {
bool isHaveCollision = CheckCollision();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isHaveCollision -> hasCollision(-s)

Comment thread gamefield.cpp Outdated
Comment on lines +137 to +183
void GameField::updateGameGrid() {
for (int i = 0; i < currentFigure_.size(); ++i) {
for (int j = 0; j < currentFigure_[0].size(); ++j) {
if (currentFigure_[i][j] == 1) {
int x = currentFigureRow_ + i;
int y = currentFigureColumn_ + j;

CheckLine();
//CheckColumn();
GameGrid_[x][y] = 1;
}
}
}
}

bool GameField::CheckCollision() {
for (int i = 0; i < currentFigure_.size(); i++) {
for (int j = 0; j < currentFigure_[0].size(); j++) {
if (currentFigure_[i][j] == 1) {
int x = currentFigureRow_ + i + 1;
int y = currentFigureColumn_ + j;

if (x < rowsNumber_ && GameGrid_[x][y] == 1) {
return true;
}
}
}
}
return false;
}


bool GameField::CheckCollisionMoveLeft() {
for (int i = 0; i < currentFigure_.size(); i++) {
for (int j = 0; j < currentFigure_[0].size(); j++) {
if (currentFigure_[i][j] == 1) {
int x = currentFigureRow_ + i;
int y = currentFigureColumn_ + j - 1;

if (y < 0 || (x < rowsNumber_ && GameGrid_[x][y] == 1)) {
return true;
}
}
}
}
return false;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все 3 методы передвижения (проверки передвижения?) - дубляж кода. Выделите общую логику в отдельный метод.

Исправлены замечания.
Корректное отображение следующей фигуры, очков и всего что необходимо по заданию.

@napstergit1 napstergit1 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Версия 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants