-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.hpp
38 lines (31 loc) · 849 Bytes
/
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
#pragma once
#include <list>
#include <random>
struct datapoint {
int x;
int y;
};
// inline int operator[](datapoint d, int i) noexcept {
// if (i == 0) return d.x;
// if (i == 1) return d.y;
// }
inline bool operator==(datapoint d1, datapoint d2) noexcept {
return (d1.x == d2.x) && (d1.y == d2.y);
}
class game {
public:
void move_snake();
bool gamebreak();
bool foodeaten();
int gridwidth = 20;
int gridheight = 20;
datapoint snake_startposition = {gridwidth / 2.0f, gridheight / 2.0f};
std::list<datapoint> snakelist = {snake_startposition};
int movement = 1;
bool gotfood = false;
std::mt19937 rng{std::random_device{}()};
std::uniform_int_distribution<int> distx{0, gridwidth - 1};
std::uniform_int_distribution<int> disty{0, gridheight - 1};
datapoint food = {distx(rng), disty(rng)};
private:
};