Skip to main content
GameDev.net gamedev.net
🔒 Locked

More state stacks!

Started by Blitz_Krieg Aug 30, 2003 at 9:20 PM 1 replies 500+ views
Original Post
Blitz_Krieg
Blitz_Krieg
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
skillfreak
skillfreak
http://www.gamedev.net/reference/programming/features/enginuity4/page2.asp

i would say look here and try to define your task system a little better. =) then come back because i will be interested in your solution.
Hope this helps,
Andy
Blitz_Krieg
Blitz_Krieg
Hey,
We are actually using aurans JET engine (somewhat unfortunately ) So main tasks, such as rendering etc. are already taken care of in a similar fashion to that.
After some more discussion with the other developers today, we;ve decided to use a rigid state stack model, similar to the other common ones that are noted on these forums, where only the top state runs etc. However we will keep the network "game" running in the back ground and able to silently load new levels in etc. It will just set some flags in the playing state, so that when/if the playing state does become active, it can catch up with what it should be doing
Thanks,
CYer, Blitz

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.