is this ok? im basically replacing a call to a single function referencing globals, by a class encapsulating all game entities and logic, the following is how i would like to call the new class in main, was just wondering what is the general c++ guru consensus on this.
class thingy
{
public:
thingy()
{
loop();
}
void loop()
{
while(true)
{
//do stuff
//if (something)
//break out
}
}
};
int main (int argc, char * const argv[])
{
thingy();
return 0;
}
It’s not common to have a constructor that contains the game/events/… loop, the usual way to do stuff like that is to use the constructor to set up the object, and then provide a separate method that starts the lengthy elaboration.
Something like this:
Actually, almost any GUI framework provides an “application” object that behaves just like that; taking e.g. the Qt framework: