Original Post
Hey,
I''m currently designing/implementing a state based program flow for the game i''m working on. The methods i''ve seen from looking through these forums and other articles implement a method where only the very top state on the stack is processed. This works fine a) When you only have a single input stream and the current state always processes this input (eg. from kb/mouse).
b) When you''re in a single-player game and you can safely Pause/Resume a state. This is an extension of a) where the second input is incoming network data.
However, the game we''re working on is multiplayer, so i need to be able to process all states that are currently on the stack. This in itself is not too much of a problem. It''s just a matter of controlling access to system resources (eg. whether a state is allowed to render or not), and updating every state on the stack every frame. With a well designed program flow, controlling access to resources may not even be neccessary.
However, the problem lies in changing states to another state.
For an example, assume i am in the "PlayingTheGame" state. If i hit ESC this will push the Menu state onto the top of the stack. The game is still running, but the Menu has access to the input etc.
Now, the problem comes if the PlayingTheGame state recieves a network message to load a new level, i want to change to my LevelLoading state. If i have other states above it in the stack, i either need to remove everything above the PlayingTheGame state and the change to the LevelLoading state, or i need to swap the PlayingTheGame state with the LevelLoading state but keep everything above. This seems ok, but i think it could end up with the possibility of some very odd things happening.
Do you think just chucking everything off the top of the stack (most likely menu screens) when i change levels would be incredibly annoying to the user? Or would this be a reasonable way to go about doing things.
Any other ideas? Does my explanation suck?
Thanks,
CYer, Blitz