feat: (snake.cpp snake.hpp) adding tail movement (broken)

This commit is contained in:
DarthMooMancer
2025-08-26 20:21:01 -04:00
parent 1bb5ecad33
commit b2c90565bc
7 changed files with 131 additions and 41 deletions
+10 -6
View File
@@ -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