while( currentState->nextState != STATE_EXIT)
{
currentState->HandleEvents();
currentState->Logic();
currentState->Render();
//if needed, change state
switch( currentState->nextState )
{
case STATE_MENU:
delete currentState;
currentState = new Menu( &GameEnvironment );
break;
case STATE_CHARSELECT:
delete currentState;
currentState = new CharSelect( CharactersChosen, GameEnvironment );
case STATE_MAPSELECT:
delete currentState;
currentState = new MapSelect( MapChosen, &GameEnvironment );
case STATE_GAME:
delete currentState;
currentState = new Game( MapChosen, CharactersChosen, &GameEnvironment );
break;
case STATE_EXIT:
break;
}
}
CharactersChosen and MapChosen are vectors that are being passed by reference. The idea was that i could send them to their appropriate States, modify them, then send them to the Game state.
BUT they are only sent to the constructors of CharSelect and MapSelect, and i need to use them in CharSelect::Logic() and MapSelect::Logic().
I have no idea what you're saying and you're not even asking any questions, but two cases in your switch have no break statement, so they'll fall right through to STATE_GAME.
that isnt my problem helios( although thank you for letting me know ).
Let me give you an example of what i want to happen.
In SuperSmashBrothersBrawl there is a screen where you can pick to play multiplayer. Lets say that is STATE_MENU. You click to play and a screen comes up where you can choose your characters, or STATE_CHARSELECT. Then another screen comes to choose the stage you would like to play on, or STATE_MAPSELECT. After all that, you can they play the game with the selected characters on the selected map.
My problem is that the way my state machine is set up, i cant figure out a way to do that^^. So im asking you to help me fix me state machine so that it would be possible to do the above.
Yeah but that wont work because each state is deleted when the next one is called, so the information is lost. I need to use information STATE_CHARSELECT and STATE_MAPSELECT to play the game. I remember reading about a statemachine with vectors but i dont really remember how to do it.
But basically, you pop on a state to the vector when you want that state to run ( it always runs the last state in the vector ) and if you need states to get information from another state you just stack them on top. Like a STATE_GAME would need information from STATE_SETTINGS, so they would be stacked. but STATE_GAME doesnt need information from STATE_MENU so STATE_MENU is deleted when its not being used.