43 lines
712 B
C++
43 lines
712 B
C++
#ifndef ELEMENT_HPP
|
|
#define ELEMENT_HPP
|
|
|
|
#include <vector>
|
|
#include "globals.hpp"
|
|
|
|
struct Point {
|
|
int m_row;
|
|
int m_col;
|
|
Point() {}
|
|
Point(int x, int y) : m_row(x), m_col(y) {}
|
|
void set_new_point(int row, int col);
|
|
void set_new_point(Point &point);
|
|
};
|
|
|
|
struct Head {
|
|
Head() : m_direction(2) {};
|
|
Point m_head {5, 5};
|
|
Point m_previous_head;
|
|
int m_direction;
|
|
void get_new_pos();
|
|
};
|
|
|
|
struct Tail {
|
|
Point m_tail_pos;
|
|
Point m_previous_tail_pos;
|
|
};
|
|
|
|
struct Body {
|
|
std::vector<Tail> m_body;
|
|
void check_new_tail();
|
|
bool check_collision(Head &head);
|
|
void get_new_pos(Head &head);
|
|
};
|
|
|
|
struct Fruit {
|
|
Fruit();
|
|
Point m_point;
|
|
void get_new_pos(char (&board)[ROW][COL], Head &head);
|
|
};
|
|
|
|
#endif // ELEMENT_HPP
|