-
Notifications
You must be signed in to change notification settings - Fork 19
/
snake.h
40 lines (35 loc) · 829 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
#ifndef _snake_h
#define _snake_h
#include "input.h"
#include <thread>
#include <semaphore.h>
#include <vector>
#include <utility>
#include "macros.h"
using namespace std;
class Snake
{
public:
Snake();
void update_direction(enum Direction direction);
void update_next_direction(enum Direction direction);
enum Direction get_direction();
void validate_direction();
vector<pair<int, int>> snake_parts;
pair<int, int> snake_head;
void update_movement();
void set_snake_food(pair<int, int> snake_food);
bool food_eaten;
bool is_dead;
int length;
private:
pthread_t input_thread;
sem_t snake_sema;
enum Direction direction;
enum Direction next_direction;
pair<int, int> snake_food;
int snake_world_array[MAP_HEIGHT][MAP_WIDTH];
void clear_snake_world();
void initialize_snake();
};
#endif