Great! That makes things easier lol.
So, not sure if you want to adopt my method, but here is how I handled game states in an unannounced project of mine:
First, I created a base class called GameState like below
//GameState
#ifndef GAMESTATE_H
#define GAMESTATE_H
class GameState
{
public:
GameState(){};
~GameState(){delete _pGame};
virtual void update(float delta);
virtual void render();
virtual void create();
virtual void discard();
protected:
GameApp* _pGame; //This is specific to my game, not sure how yours works
};
#endif
Now that we have the base game state class down, you can start creating other states. In this example, I'll make a introState.
#ifndef INTROSTATE_H
#define INTROSTATE_H
#include "GameState.h"
class introState : public GameState
{
public:
introState();
~introState();
//These were inherited
virtual void update(float delta);
virtual void render();
virtual void create();
virtual void discard();
private:
int someVar;
};
#endif
For the implementation, (the code inside is specific to my game, you will want to change it. I'm giving you the general idea)
#include "introState.h"
introState::introState(GameApp * Game)
{
_pGame = Game;
this->create();
}
introState::~introState()
{
this->discard();
_pGame = NULL; //or delete _pGame
}
void introState::create()
{
someVar = 0;
}
void introState::discard()
{}
void introState::update(float delta)
{
someVar = someVar + delta;
}
void introState::render()
{
printf("%i", someVar);
}
Now that you have the two files, introstate.h and introstate.cpp done, you just need to use them.
So somewhere, you will include gamestate.h and introstate.h, along with the std library stack. You'll want to use a stack, as it serves the purpose of managing your states well.
so you would do something like the following
stack<GameState> gameStates;
intro = new introState(this); //this refers to the gameApp class in this example (specific code to my game)
mainMenu = new mainMenuState(this);
gameStates.push(intro); //This puts the intro state to the top
then in your update loop
gameStates.top()->update(delta);
and in your render loop
gameStates.top()->render();
You'll want to make some functions that handle the stack as well (accessors). Such things can be changeState, which will push a new state to the top, or you can do something like removeState, which pops the top state off, revealing the state under it. This allows you to have some pretty complex menus without the complexity, if that made sense