refactor: removing a bunch of random bad code and fixing it with more readable code
This commit is contained in:
+10
-12
@@ -11,13 +11,14 @@ struct Body;
|
||||
struct Fruit;
|
||||
|
||||
struct Point {
|
||||
int m_row;
|
||||
int m_col;
|
||||
int m_direction;
|
||||
Point() {}
|
||||
Point(int x, int y) : m_row(x), m_col(y) {}
|
||||
Point(int x, int y, int dir) : m_row(x), m_col(y), m_direction(dir) {}
|
||||
void set_new_point(int row, int col, int dir);
|
||||
int m_row;
|
||||
int m_col;
|
||||
int m_direction;
|
||||
Point() {}
|
||||
Point(int x, int y) : m_row(x), m_col(y) {}
|
||||
Point(int x, int y, int dir) : m_row(x), m_col(y), m_direction(dir) {}
|
||||
void set_new_point(int row, int col, int dir);
|
||||
void set_new_point(Point &point);
|
||||
};
|
||||
|
||||
struct Head {
|
||||
@@ -33,19 +34,16 @@ struct Tail {
|
||||
};
|
||||
|
||||
struct Body {
|
||||
Body() : m_score(0), m_collision(false) {};
|
||||
std::vector<Tail> m_body;
|
||||
int m_score;
|
||||
bool m_collision;
|
||||
void check_new_tail();
|
||||
void check_collision(Head &head);
|
||||
bool check_collision(Head &head);
|
||||
void get_new_pos(Head &head);
|
||||
};
|
||||
|
||||
struct Fruit {
|
||||
Fruit(char (&board)[ROW][COL]);
|
||||
Point m_point;
|
||||
void get_new_pos(char (&board)[ROW][COL], Head &head, int &score);
|
||||
void get_new_pos(char (&board)[ROW][COL], Head &head);
|
||||
};
|
||||
|
||||
#endif // ELEMENT_HPP
|
||||
|
||||
Reference in New Issue
Block a user