Original Post
Hello forum!
Something that has been quite a hassle for me too wrap my head around is the managing of screens/states.
Basically I have a base class called "State" or "Screen" that each State/Screens inherit from.
Each screen has a boolean called "finished" that returns true if the state is done and should be deleted/switched with another state. The state must also have support for childs, better known as states withing states such as InventoryState that acts within the WorldState ( Actual game ) or PauseState that is another state above WorldState.
Childstates are small states and pieces of game logic inside a the State stack that tells the Game-Loop to NOT de-allocate the states before itself, ( Seeing as it's a child of it and is supposed to go back to it soon ) as well as having the ability to determine if the parent state should update and/or render itself WHILE the childstate is active! Think a small popup window when you level up inside a battlestate, the battlestate still renders but does not update logic other than animations.
This is roughly the system I'm trying to achieve, coding it isn't very hard it's more how I grant access to the states to push new states into the stacks.
I think the best way would be to pass the stack wrapped inside a class with the method only to push new states into the the stack, that way a class only have access to the feature they SHOULD and WILL use.
But I'm not sure, is this unnecessary? Is their a cleaner way to do it?
Thanks beforehand!
Something that has been quite a hassle for me too wrap my head around is the managing of screens/states.
Basically I have a base class called "State" or "Screen" that each State/Screens inherit from.
Each screen has a boolean called "finished" that returns true if the state is done and should be deleted/switched with another state. The state must also have support for childs, better known as states withing states such as InventoryState that acts within the WorldState ( Actual game ) or PauseState that is another state above WorldState.
Childstates are small states and pieces of game logic inside a the State stack that tells the Game-Loop to NOT de-allocate the states before itself, ( Seeing as it's a child of it and is supposed to go back to it soon ) as well as having the ability to determine if the parent state should update and/or render itself WHILE the childstate is active! Think a small popup window when you level up inside a battlestate, the battlestate still renders but does not update logic other than animations.
This is roughly the system I'm trying to achieve, coding it isn't very hard it's more how I grant access to the states to push new states into the stacks.
I think the best way would be to pass the stack wrapped inside a class with the method only to push new states into the the stack, that way a class only have access to the feature they SHOULD and WILL use.
But I'm not sure, is this unnecessary? Is their a cleaner way to do it?
Thanks beforehand!