-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.h
57 lines (46 loc) · 1.47 KB
/
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
54
55
56
57
#include <deque>
#ifndef SnakeDefs //prevents overdefining with a precursor
#define SnakeDefs
#include "board.h"
#include "food.h"
class Snake{
private:
int speed;
char direction;
public:
bool dead; //public so it can be accessed in main easily
std::deque<int> xDeque; //will store the x coordinates
std::deque<int> yDeque; //will store the y coordinates
int xLocation;
int yLocation;
int bellyCount; //how much the snake has eaten
int length;
Snake(); //default constructor
Snake(int iSpeed); //constructor
Snake(const Snake& iSnake); //copy constructor
Snake& operator =(const Snake& iSnake){ //assignment operator
speed = iSnake.speed;
length = iSnake.length;
dead = iSnake.dead;
bellyCount = iSnake.bellyCount;
xLocation = iSnake.xLocation;
yLocation = iSnake.yLocation;
xDeque = iSnake.xDeque;
yDeque = iSnake.yDeque;
}
~Snake();
void initSnake(); //puts the first snake coordinates in the deque
void addSnake(); //modifies coordinates in the deque
void moveSnake(Board& gBoard); //moves the snake with variant speed
void drawSnake(Board& gBoard); //draws a snake to the board
void eraseSnakeTail(Board& gBoard);
void eatFood(Board& gBoard); //lengthens the snake when it eats a food
void isDead(); //will end the game if method is called by changing dead status
//directional methods
void moveUp();
void moveDown();
void moveRight();
void moveLeft();
};
int kbhit();
#endif