fix(snake.cpp .hpp): first step to extracting tail functions and head movement to just head and tail separately
This commit is contained in:
+1
-1
@@ -2,6 +2,7 @@
|
||||
#define POINT_HPP
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Point {
|
||||
@@ -12,7 +13,6 @@ struct Point {
|
||||
|
||||
std::string to_string() const;
|
||||
void clear(std::array<std::array<char, COL>, ROW> &arr) const;
|
||||
void get_new_point(int direction);
|
||||
};
|
||||
|
||||
#endif // POINT_HPP
|
||||
|
||||
+8
-6
@@ -23,19 +23,21 @@
|
||||
* separate the snake and tail from each other
|
||||
* */
|
||||
|
||||
struct Snake {
|
||||
Snake(int default_direction, int row, int col);
|
||||
struct Head {
|
||||
Head(int default_direction, int row, int col);
|
||||
Point m_head;
|
||||
std::vector<Point> m_tails;
|
||||
// 1: Down, 2: Up, 3: Left, 4: Right
|
||||
// -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 {
|
||||
//
|
||||
// }
|
||||
struct Tail {
|
||||
Point m_tail_pos;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user