nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
Globals.hpp
1#ifndef GLOBALS_H_DEFINED
2#define GLOBALS_H_DEFINED
3
4#include <Engine/Graphics/Colors.hpp>
5
6#include <string>
7
8// Avoiding cyclic #includes
9struct ScoreEntry;
10
30namespace Globals
31{
33 void init();
34
38 void loadFile();
39
43 void saveFile();
44
50 void warnErrors();
51
52 // Accessing version numbers - version[MAJOR] for example
53#define MAJOR 0
54#define MINOR 1
55#define PATCH 2
56
66 extern char version[3];
67
68 namespace Config
69 {
75 extern std::string directory;
76
80 extern std::string file;
81
85 extern std::string scoresFile;
86 };
87
88 namespace Game
89 {
90 extern unsigned int starting_speed;
91
92 extern int fruits_at_once;
93 extern bool random_walls;
94 extern bool teleport;
95
96 // The board size
97 enum BoardSize
98 {
99 SMALL, MEDIUM, LARGE
100 };
101 BoardSize intToBoardSize(int val);
102 int boardSizeToInt(BoardSize size);
103
104 extern BoardSize board_size;
105
106 extern int board_scroll_delay;
107
108 extern bool board_scroll_up;
109 extern bool board_scroll_down;
110 extern bool board_scroll_left;
111 extern bool board_scroll_right;
112
115 extern std::string current_level;
116 };
117
118 namespace Theme
119 {
120 extern ColorPair player_head;
121 extern ColorPair player_head_dead;
122 extern ColorPair player_body;
123 extern ColorPair fruit;
124 };
125
126 // Flags to warn the user of some error at the end
127 // of execution.
128 namespace Error
129 {
131 extern bool has_config_file;
132
134 extern bool has_score_file;
135
137 extern bool old_version_score_file;
138
140 extern bool strange_score_file;
141 };
142};
143
144#endif //GLOBALS_H_DEFINED
145
Definition Game.hpp:17
Container for global settings on the game.
Definition Globals.hpp:31
void init()
Initializes global variables with default values.
Definition Globals.cpp:78
char version[3]
Game version (format MMP - Major Minor Patch).
Definition Globals.cpp:15
void warnErrors()
Warns the user about any errors and warnings found during the program's execution.
Definition Globals.cpp:371
void loadFile()
Loads global variables from the default file.
Definition Globals.cpp:141
void saveFile()
Loads global variables to the default file.
Definition Globals.cpp:262
A single entry on the high-score file.
Definition ScoreFile.hpp:28