33 lines
691 B
C++
33 lines
691 B
C++
#ifndef SNAKE_HPP
|
|
#define SNAKE_HPP
|
|
|
|
#include <vector>
|
|
#include "point.hpp"
|
|
|
|
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 {
|
|
Tail(int follow_direction, int row, int col);
|
|
Point m_tail_pos;
|
|
Point m_previous_tail_pos;
|
|
std::vector<Point> m_move_history;
|
|
void get_previous_point();
|
|
};
|
|
|
|
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);
|
|
void get_new_points(Head &head);
|
|
void collision(Head &head, bool &running);
|
|
};
|
|
|
|
#endif
|