-
Notifications
You must be signed in to change notification settings - Fork 14
Tetris v.1 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Tetris v.1 #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #ifndef PIECE_H | ||
| #define PIECE_H | ||
| #include <QBrush> | ||
| #include <vector> | ||
| class Piece | ||
| { | ||
| public: | ||
| std::vector<std::vector<int> > PieceArray; | ||
| int PieceColor; | ||
| int X, Y; | ||
| }; | ||
| #endif // PIECE_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #include "figures.h" | ||
| Figures::Figures() | ||
| { | ||
| } | ||
| Figures::~Figures() | ||
| { | ||
| } | ||
|
Comment on lines
+2
to
+7
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Скобки либо везде не переносим (как принято у нас в стиле), либо везде переносим, если принципиально, но всегда в одном стиле. Исправьте во всем проекте в единый стиль. |
||
| std::vector<std::vector<int> > Figures::getFigure(int figure, int state) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Методы отделяем друг от друга пустой строкой. Лишний пробел |
||
| if ( figure < 1 ) figure = 1; | ||
| else if ( figure > 7 ) figure = 7; | ||
| if ( state < 1 ) state = 1; | ||
| else if ( state > 4 ) state = 4; | ||
| std::vector<std::vector<int> > v; | ||
| for ( int i = 0; i < 4; i++ ) { | ||
|
Comment on lines
+9
to
+14
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1, 4, 7 и т.д. в коде ниже - магические значения. Что это ? Как понять? Выделите в поля / переменные. |
||
| std::vector<int> a; | ||
| for ( int j = 0; j < 4; j++ ) { | ||
| if ( figure == 1 ) { | ||
| a.push_back(Figures::figure1_1[i][j]); | ||
| } else if ( figure == 2 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure2_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure2_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure2_3[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure2_4[i][j]); | ||
| } | ||
| } else if ( figure == 3 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure3_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure3_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure3_3[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure3_4[i][j]); | ||
| } | ||
| } else if ( figure == 4 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure4_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure4_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure4_3[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure4_4[i][j]); | ||
| } | ||
| } else if ( figure == 5 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure5_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure5_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure5_3[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure5_4[i][j]); | ||
| } | ||
| } else if ( figure == 6 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure6_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure6_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure6_3[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure6_4[i][j]); | ||
| } | ||
| } else if ( figure == 7 ) { | ||
| if ( state == 1 ) { | ||
| a.push_back(Figures::figure7_1[i][j]); | ||
| } else if ( state == 2 ) { | ||
| a.push_back(Figures::figure7_2[i][j]); | ||
| } else if ( state == 3 ) { | ||
| a.push_back(Figures::figure7_1[i][j]); | ||
| } else if ( state == 4 ) { | ||
| a.push_back(Figures::figure7_2[i][j]); | ||
| } | ||
| } | ||
|
Comment on lines
+19
to
+79
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Весь блок явно должен быть левее по отступам. |
||
| } | ||
| v.push_back(a); | ||
| } | ||
| return v; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| #ifndef FIGURES_H | ||
| #define FIGURES_H | ||
|
|
||
| #include <vector> | ||
| class Figures | ||
|
Comment on lines
+4
to
+5
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Пустая строка между подключениями и прочим. |
||
| { | ||
| public: | ||
| Figures(); | ||
| virtual ~Figures(); | ||
| int figure1_1[4][4] = { | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure2_1[4][4] = { | ||
| { 0, 0, 1, 1 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure2_2[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure2_3[4][4] = { | ||
| { 0, 0, 1, 1 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure2_4[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure3_1[4][4] = { | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure3_2[4][4] = { | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 0, 0, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure3_3[4][4] = { | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure3_4[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure4_1[4][4] = { | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure4_2[4][4] = { | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure4_3[4][4] = { | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure4_4[4][4] = { | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure5_1[4][4] = { | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure5_2[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure5_3[4][4] = { | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure5_4[4][4] = { | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure6_1[4][4] = { | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure6_2[4][4] = { | ||
| { 0, 0, 0, 1 }, | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure6_3[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 1, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure6_4[4][4] = { | ||
| { 0, 1, 1, 1 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure7_1[4][4] = { | ||
| { 1, 1, 1, 1 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 }, | ||
| { 0, 0, 0, 0 } | ||
| }; | ||
| int figure7_2[4][4] = { | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 0, 0 }, | ||
| { 0, 1, 0, 0 } | ||
| }; | ||
| std::vector<std::vector<int> > getFigure(int figure, int state); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Методы с большой буквы |
||
| protected: | ||
| private: | ||
|
Comment on lines
+149
to
+150
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Зачем тут эти модификаторы, если они пустые? |
||
| }; | ||
|
|
||
| #endif // FIGURES_H | ||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Блоки Include Отделяем от всего остального пустой строкой