-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.h
More file actions
41 lines (35 loc) · 815 Bytes
/
game.h
File metadata and controls
41 lines (35 loc) · 815 Bytes
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
#ifndef SNAKEGAME_GAME_H
#define SNAKEGAME_GAME_H
#include <deque>
#include <ncurses.h>
#include <unistd.h>
#include <random>
#include <ctime>
#include "pos.h"
class Game {
private:
char m_snakeSymbol;
char m_foodSymbol;
int m_userInput;
uint32_t m_difficulty;
int m_row;
int m_col;
uint32_t m_score;
position m_food;
std::deque<position> m_snake;
enum m_direction {UP, DOWN, LEFT, RIGHT};
m_direction m_dir;
void initGame();
void spawnFoodRand();
void drawBoard() const;
void drawSnake() const;
void printScore() const;
[[nodiscard]] bool checkForFood() const;
[[nodiscard]] bool checkForLoss() const;
void moveSnake(bool);
public:
Game(char, char, uint32_t);
~Game();
void run();
};
#endif // !SNAKEGAME_GAME_H