-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.hpp
49 lines (46 loc) · 1.22 KB
/
game.hpp
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
#include <string>
#include <iostream>
#include <memory>
#include <vector>
// #include "food.hpp"
class shared_state;
class game : public std::enable_shared_from_this<game>
{
class snakebody
{
public:
int x, y;
snakebody(int x_, int y_) {
x = x_;
y = y_;
}
std::string strrep() const {
return std::to_string(x)+","+std::to_string(y);
}
};
// food foodtoken;
int foodx, foody;
int height, width;
int headx, heady, headx2, heady2;
int snakelength, snakelength2;
std::vector <snakebody> snakeparts;
std::vector <snakebody> snakeparts2;
enum eDirection {STOP, LEFT, RIGHT, UP, DOWN};
eDirection prevdir;
eDirection dir;
eDirection prevdir2;
eDirection dir2;
bool gameRunning;
public:
game();
void setDirection(std::string directionfull);
void setDirection2(std::string direction);
void updatefood();
void reset();
void moveall();
void move();
void move2();
void render(std::shared_ptr<shared_state> const& state);
void gameloop(std::shared_ptr<shared_state> const& state);
// void prepGameThread(std::shared_ptr<shared_state> const& state);
};