-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCSnake.h
61 lines (55 loc) · 901 Bytes
/
CSnake.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
54
55
56
57
58
59
60
61
/*
* Developed By : Lorenzo T.Leonardo
* Date : March 23, 2022
* Email : [email protected]
*/
#pragma once
#include <algorithm>
#include <vector>
#include "CPosition.h"
enum class Snake_Direction
{
UP, DOWN, RIGHT, LEFT
};
class CSnake : public CPosition
{
private:
std::vector<COORD> m_vBody;
COORD m_head;
COORD m_tail;
Snake_Direction m_direction;
int m_nlength;
bool m_bIsAlive;
inline void checkBodyCollision();
public:
CSnake(COORD coord);
~CSnake();
void crawl();
void grow(COORD pos);
void growBonus(COORD pos, int nLength);
void setDirection(Snake_Direction dir);
std::vector<COORD> getBodyLocation()
{
return m_vBody;
}
bool isAlive()
{
return m_bIsAlive;
}
COORD getTail()
{
return m_tail;
}
COORD getHead()
{
return m_head;
}
Snake_Direction getDirection()
{
return m_direction;
}
int getLength()
{
return m_nlength;
}
};