Hi,
I'm trying to figure out the basics in state design. I don't quite get it.
Say I have an enum GameState{ MAIN, ABOUT, ADVENTURE, QUIT}
, how do I proceed from there?
class Game{
class state *current;
public:
Game();
void setState(State *){
current = s;
}
void Main();
void Adventure();
void About();
void Quit;
}
class State{
public:
virtual void main(Game *g){
//in main;
}
virtual void adventure(Game *g){
//playing adventure
}
virtual void about(Game *g){
//in About
}
virtual void quit(Game *g){
//quit game when in this state
}
}
void Game::Main(){
current->main(this);
}
void Game::About(){
current->About(this);
}
//the rest of game functions.. Game::Adventure(), Game::Quit().
class Adventure: public State{
public:
render();
quit(Game *g);
main(Game *g);
}
//the rest of the class will be basically the same...
As you can see.. I didn't impement the enum GameState, how can I implement GameState? Should I? I was told that using enum is the way when dealing with state design. the code snipet is what I currently have in mind.