-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnake.h
53 lines (38 loc) · 854 Bytes
/
Snake.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <deque>
// pair를 사용할 때 first는 Y, second는 X
#define Y first
#define X second
using namespace std;
// SNAKE 머리 방향
namespace SNAKE_HEAD_DIRECTION {
const int LEFT = 0;
const int UP = 1;
const int RIGHT = 2;
const int DOWN = 3;
};
typedef pair<int, int> pos;
const pos dPos[4] = {
{0, -1},
{-1, 0},
{0, 1},
{1, 0}
};
class Snake {
deque<pos> snake;
int direction;
public:
Snake(const int& y, const int& x);
const pos& head();
const pos new_head();
// portal 용
void move_head(const pos new_pos);
const pos& tail();
void set_head_direction(int direction);
int get_head_direction();
int get_snake_length();
void grow();
// portal 용
void grow(const pos new_pos);
void shrink();
void reverse();
};