I have a state machine in my game that closely follows the LazyFoo one : http://lazyfoo.net/articles/article06/index.php
This means I have a
BaseState *currentState = NULL;
which is then set via a function that is called each loop and a flag "nextState"
when the next state is not null, a switch is entered where the next state is created as follows:
switch( nextState )
{
case TITLE_STATE:
currentState = new TitleState();
break;
case INTRO_STATE:
currentState = new IntroState();
break;
then nextState is set to null again, rinse and repeat.
-----------------
Now,
Everything that happens in the game happens from this state. The rendering is
currentState->render();
same with the logic, event handling, etc.
The character, the world map, the level data, EVERYTHING exists inside of these states.
My question is this - Does this mean that my whole game will operate from the heap, even though my objects like Character and Level are declared as
Character character();
Level level();
This would lead me to believe that the Character and Level would be on the stack, but since their parent class is on the heap (currentState->character, and currentState->level), are they too on the heap? If so, would it be prudent to try and redesign this so that all the states are on the stack?
Thank You