fix: (tail) fixed where tail index 0 is on top of the head
This commit is contained in:
+4
-22
@@ -4,30 +4,12 @@
|
||||
#include <vector>
|
||||
#include "point.hpp"
|
||||
|
||||
/* NOTE
|
||||
* tail
|
||||
* ARGS
|
||||
* - direction
|
||||
* - old point
|
||||
* - new point
|
||||
* - new direction (x and y of old point and what direction it needs to swtich to so once it gets to it changes)
|
||||
* - symbol
|
||||
* IMPLEMENTATION
|
||||
* - predict the new point
|
||||
* - save old point
|
||||
* - find if previous tail has new direction
|
||||
* - once tail hits point change direction
|
||||
*/
|
||||
|
||||
/* Struct Tail
|
||||
* separate the snake and tail from each other
|
||||
* */
|
||||
|
||||
|
||||
struct Head {
|
||||
Head(int default_direction, int row, int col);
|
||||
Point m_head;
|
||||
Point m_previous_head;
|
||||
void get_new_point(int direction);
|
||||
void get_previous_point();
|
||||
};
|
||||
|
||||
struct Tail {
|
||||
@@ -35,8 +17,7 @@ struct Tail {
|
||||
Point m_tail_pos;
|
||||
Point m_previous_tail_pos;
|
||||
std::vector<Point> m_move_history;
|
||||
// void set_point(Point &d);
|
||||
void get_new_point();
|
||||
void get_previous_point();
|
||||
};
|
||||
|
||||
struct Body {
|
||||
@@ -44,6 +25,7 @@ struct 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);
|
||||
void get_new_points(Head &head);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user