Original Post
I've written a basic engine and api to build a game. But now I find myself wondering how to do it. Somehow tracking a game state and using a giant switch statement doesn't feel like the best way to do it, it wouldn't be really flexible. So, how does everyone else do it? I don't know how everyone else's engine's work, I use what I like to call a base class which you inherit from and it has functions called from the engine at whatever time...init() destroy() cycle() event(). So getting started is as simple as deriving a class and passing an instance of it to the engine object. Hopefully this makes sense. I was thinking, perhaps I could modify it slightly so that I could easily swap bases. This would require wrapping the engine and however many base classes in another class though and routing calls between the wrapper and the selected base class to manage the game state. I'm not sure if this is really, flexible, enough though. How do you guys do it?
class DEMO:public CQBase{
public:
void init();
void cycle();
void event(CQEvent);
void destroy();
};
...
DEMO d;
CQEngine engine(&d);
engine.window.init(1024,768,16,"CQDemo",false);
engine.run()