48 lines
958 B
C++
48 lines
958 B
C++
#ifndef SNAKE_HPP
|
|
#define SNAKE_HPP
|
|
|
|
#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;
|
|
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
|