-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake.h
33 lines (21 loc) · 764 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
#pragma once
enum direction { stop = 0, left, right, up, down };
//function to check if there is a specific number in an array
int findInArr(int arr[], int arrSize, int num);
//snake class used to move the snake and store variables for it
class snake
{
public:
int x, y; //position of the snake head
direction dir = stop; //direction of movement
int tailX[100], tailY[100]; //tail positions with max size 100
int length = 0; //tail length
//initialize variables
void initializePos(int x, int y);
//save the tail
void saveTail();
//move the snake according to dir variable
void move();
//change direction according to given charachter
void turn(char c);
};