nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
Game.hpp
1#ifndef GAME_H_DEFINED
2#define GAME_H_DEFINED
3
4#include <Game/ScoreFile.hpp>
5#include <Game/Player.hpp>
6#include <Game/Board.hpp>
7#include <Game/FruitManager.hpp>
8#include <Misc/Timer.hpp>
9#include <Interface/Menu/Menu.hpp>
10
11#include <vector>
12
13// Pre-defining it's layout to avoid circular dependency.
14class LayoutGame;
15
16class Game
17{
18 friend class LayoutGame;
19
20public:
21 Game();
22 virtual ~Game();
23
34 void start(std::string levelName="");
35
36 void handleInput();
37 void update();
38 void draw();
39
40 bool isOver();
41
43 bool willQuit();
44
46 bool willReturnToMenu();
47
50 int getDelay(int speed);
51
52 void pause(bool option);
53
54 // GameStateGame needs them to be public
55
60
67
68protected:
69 LayoutGame* layout;
70
73
74 bool userAskedToQuit;
75 bool userAskedToGoToMenu;
76
80
84
85 // Times how long the user have been playing the game.
86 Timer timer;
87
91
95
99
102
103 Player* player;
104 Board* board;
105 FruitManager* fruits;
106};
107
108#endif //GAME_H_DEFINED
109
A level where the snake runs and eats fruits.
Definition Board.hpp:33
Controls how many Fruits are there and how they're spawned.
Definition Game.hpp:17
bool gameOver
If the game is over (board is full of blocks).
Definition Game.hpp:72
void start(std::string levelName="")
Starts game, optionally loading a level.
Definition Game.cpp:39
int getDelay(int speed)
Returns how much time (millisseconds) we need to wait for a specific #speed.
Definition Game.cpp:327
ScoreEntry * currentScore
Current score for this level.
Definition Game.hpp:66
Menu * pauseMenu
Menu that's shown only when the user presses Pause.
Definition Game.hpp:101
bool isPaused
If the game is paused.
Definition Game.hpp:90
bool showPauseMenu
If it's showing the pause menu.
Definition Game.hpp:94
bool showHelp
If it's showing the help screen.
Definition Game.hpp:98
ScoreFile * scores
All the current level's score.
Definition Game.hpp:59
bool willQuit()
If we'll quit the game right away.
Definition Game.cpp:319
Timer timerSnake
Timer that tells when to move the player, based on the current speed).
Definition Game.hpp:79
bool willReturnToMenu()
If we'll return to the main menu.
Definition Game.cpp:323
Timer timerBoard
Timer that tells when to scroll the board, if this game setting is activated.
Definition Game.hpp:83
List of selectable items.
Definition Menu.hpp:29
Stores points the player made on the game.
Definition ScoreFile.hpp:88
Definition Timer.hpp:8
A single entry on the high-score file.
Definition ScoreFile.hpp:28