It's usually preferred to have your own headers before library headers. This can help avoid possible dependencies and also keep the headers more organized.
Do not use
using namespace std
in a header file. It can be okay to have it in an implementation file due to the locality (.cpp files do not get imported), but having it in a header file will force users to have thestd
namespace
exposed, which can possibly break their code. Just leave it out and usestd::
where appropriate.Macro constants (or macros in general) are not very common in C++, and are primarily discouraged as there are better ways of doing things. Specifically, the
const
keyword should be used to make something constant and prevent any further changes to it.const int WORLD_HEIGHT = 4;
Moreover, as these are in a header file, they will be global by default. While it is not such a bad thing since they cannot be modified, it would be safer to have them contained within a
namespace
or a class (only if it belongs in a class).namespace vals { const int WORLD_HEIGHT = 4; // ... }
The constant can then be accessed via the scope operator (
::
):int height = vals::WORLD_HEIGHT;
Note(Note: The name
vals
is only an example, so feel free to give a more relevant name. As a user may be using it frequently (unlessusing
is used), try to make it short.)If it does belong in a class, then make it a
static const
type (it must bestatic
as it belongs to the class itself and not the individual objects). If it's an integer type, it can be initialized inside the class declaration aspublic
, otherwise it'll have to be done in the implementation file.The scope access concept still applies, except you'll use the class name:
int height = Class::WORLD_HEIGHT;
You can omit the
ChunkManager
constructor since you aren't already overwriting it. The compiler will provide a default one for you.Also,
void
parameters are not needed in C++, unlike in C. The compiler will already know that such call takes no arguments.It's a little confusing to have multiple
public
andprivate
sections. Just group them into one.Also,
centerLoaded
should beprivate
as it is a data member. That should not be exposed to the public interface.