Mario Recreation
This was the 2nd prototype game that I had created within C++ and the first time that I had delved
into SDL2. This framework is very well documented and the documentation was easy to understand.
I am going to be talking about some of the things that I learnt within this project
Code: https://github.com/deadmonstor/Games-Engine-Creation
Things I learnt:
CPP:
class* class::mInstance = class::mInstance == nullptr ? NULL : class::mInstance;
class* class::Instance()
{
if (!mInstance)
mInstance = new class();
return mInstance;
}
Header:
class class
{
private:
static class* mInstance;
};
This allowed me to write code like this. Obviously you will probably want to store this within a
variable and not just directly call the Instance function everything you want to do anything.
CPP:
class::Instance()->function();
#define RENDERUPDATE 1
#define PRETICK 2
#define POSTTICK 3
#define PREMAPCHANGE 4
#define POSTMAPCHANGE 5
The order that the default game loop would go through is PRETICK -> RENDERUPDATE -> POSTTICK
within the PRETICK and RENDERUPDATE events there was the ones that SDL2 injected which made it so that
you could control the camera with your mouse and keyboard. Having this system in place made me
understand the reason why UE4 and Unity do this in the first place.