I'm hoping that some experienced programmers can give me their point of view. I'm writing a large game in Windows with dx11. So far, I've got global objects of the class that interfaces with dx11, the class holding the position of the camera, the terrain data class, and a few other classes. In future, if I kept going with this way, I'd also have objects for all the game data, and so on.
I'm thinking it might be best to rejig the code to only have local variables, because generally this is regarded as a Good Thing, but mainly because I personally have come to prefer using them. Here's some rough c++-ish pseudo-code of how I imagine local variables would be implemented:
WinMain()
{
cDirectX dx;
cCamera cam;
cTerrain terrain;
...
while (msg.message != WM_QUIT)
{
...
gameLoop(dx, cam, terrain, ...)
}
}
void gameLoop(cDirectX &dx, cCamera &cam, cTerrain &terrain, ...)
{
...
renderTerrain(dx, terrain);
...
}
Is this (very roughly!) a good way to organise such a project? I suppose WinMain is the only function where the locals can be instantiated?
The only disadvantage I can see is that top level function calls (by which I mean, functions like gameLoop(), functions at the bottom of the call stack) will have very long lists of arguments. Perhaps this doesn't matter.
Thanks, Paul