Files
snake/include/snake.hpp
T

44 lines
924 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;
std::vector<Point> m_tails;
// -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 {
Point m_tail_pos;
std::vector<Point> m_move_history;
};
#endif