feat: (snake.cpp snake.hpp) adding tail movement (broken)
This commit is contained in:
+10
-6
@@ -23,21 +23,25 @@
|
||||
* separate the snake and tail from each other
|
||||
* */
|
||||
|
||||
|
||||
struct Head {
|
||||
Head(int default_direction, int row, int col);
|
||||
Point m_head;
|
||||
std::vector<Point> m_tails;
|
||||
// -1: Left, 1: Right, 2: Down, -2: Up
|
||||
int m_direction;
|
||||
// Adds a new tail to m_tails at { row, col }
|
||||
void create_tail(int row, int col);
|
||||
void get_new_head_point(int tail_index, int direction);
|
||||
void get_new_point(int direction);
|
||||
};
|
||||
|
||||
struct Tail {
|
||||
Tail(int follow_direction, int row, int col);
|
||||
Point m_tail_pos;
|
||||
std::vector<Point> m_move_history;
|
||||
void get_new_point(Point &d);
|
||||
};
|
||||
|
||||
struct Body {
|
||||
std::vector<Tail> m_body;
|
||||
void clear(std::array<std::array<char, COL>, ROW> &arr);
|
||||
void draw(std::array<std::array<char, COL>, ROW> &arr);
|
||||
void move(Head &head);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user