Skip to content

TetrisMy#13

Open
pahanmar wants to merge 4 commits into
hBuzzy:masterfrom
pahanmar:master
Open

TetrisMy#13
pahanmar wants to merge 4 commits into
hBuzzy:masterfrom
pahanmar:master

Conversation

@pahanmar

Copy link
Copy Markdown

No description provided.

1)Реализован тетрис с генерацией  фигур и  поворотами

@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 figure.cpp Outdated
Figure::Figure() {}

void Figure::generateFigure(){
QVector<QVector<QVector<int>>> arrayOfFigures;

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.

У вас тут вектора, что уже конфликтует с названием array. Обычно мы называем контейнеры просто во множественном числе того, что в нем храним. В вашем случае просто figures будет достаточно.

Comment thread figure.cpp Outdated
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();

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 figure.cpp Outdated
int type = rand() % arrayOfFigures.size();
figure_ = arrayOfFigures[type];
}
int Figure::getXPoints() const{

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 figure.cpp Outdated

Figure::Figure() {}

void Figure::generateFigure(){

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 figure.cpp Outdated
return figure_.size();
}

int Figure::getYPoints() const{

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
};
}

void GameField::startNewGame(){

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

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; } ) ) {

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 20 to 22
void RowsNumberChanged();
void ColumnsNumberChanged();
void InitialisationStarted();

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.

Раз оформляете методы с маленькой буквы, то приведите все, что связано с Q_PROPERTY в соответствующий вид.

Comment thread gamefield.h Outdated
Comment on lines +46 to +47
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);

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.

Не стоит превращать методы в слоты, вынесите paintEvent и keyPressEvent вне слотов.

Comment thread gamefield.cpp Outdated
}

void GameField::clearLines() {
for (int i = 0; i <= gameField_.size( )- 1; i++) {

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.

gameField_.size( )- 1 -> gameField_.size() - 1

1)Исправлена стилистика
2)Создан класс drawFigure
1)Добавлена структура QPoint
2)Переделана функция rotate()

@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.cpp
currentYPosition_++;
emit moveFigure();
}else {
}else {

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.

Перед else пробел

Comment thread gamefield.cpp

void GameField::moveFigureRight() {
if(!isCollision(currentFigure_, 1, 0)) {
if(!isCollision(currentFigure_, 1, 0)) {

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.

Пробел после If

Comment thread gamefield.cpp
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);

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
emit moveFigure();
if(isCollision(currentFigure_, 0, 0)){
startNewGame();
if(isCollision(currentFigure_, 0, 0)) {

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.

Пробел после if

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