I have written small game in Directx with animated meshes, sound, GUI and takes in user input via windows messages.
I have determined that my code is kinda chaotic. I am passing down pointers to new object instances, copy them and store them locally, all just to avoid global variables. A lot of "tweaks" just to satisfy all those "don't do that" threads around here.
Now, I want to rewrite the code and my idea is to have a Super Game Class. Such that I can do the following
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//Some Window code
MySuperClass MyGame;
MyGame.init();
My.Game.run();
MyGame.cleanup();
return 0;
}
//The WindowProc function goes here
The idea is that LPDIRECT3DDEVICE9 device and others can be member variables of MyGame. Then inside MyGame I can pass down "this" and get all the variables I need down to the functions that need them.
Is this a bad or a good idea?
Also, when I pass down "this" to the render classes at init, I make a copy such that all the sub classes can reference the Super Parent with all its children and member variables.






