I have a project, for example game application. I have a lot of classes in there. So, where should I store initial variable declaration/definition of game parameters?
For example, I have a 'plane' which has initial parameters speed
,height
, e.t.c.
After game has started this parameters somehow depends on game process, and changing in time parameters I should also store in some file.
The same situation with another classes, for example initial score
/fuel
/health
...
Also there is some constexpr
parameters like quantity of added score per seconds.
So, where should I store all this parameters? I have some idea about that:
- If I store it in
Parameters.h
file like:
namespace WINDOW_PARAM {
static const unsigned int WIDTH = 1000;
static const unsigned int HEIGHT = 1000;
}
namespace PLANE_PARAM {
static const char *TEXTURE_PATH = "../example.png";
}
then I will get my compilation time too big. That's because some classes contains this file, and If I test best-parameters I will modify it and it's will be too long.
- Another way - create config file and somehow parse from it. That's will decrease compile time and easy to modify, but it seems hard in architecture cases, because there are will be a lot of dependencies.
- Just declare each constant in each class. - too long to modify, because I should open
Plane.h
- modify, thenWindow.h
.. e.t.c
How big project game solve this problem (it means that they are testing/developed - should build less and keep simple architecture)? Is it a good practice to use extern
like an answer below?