As far as I can tell, most games have some sort of "game state system" which switches between the different game states; these might be things like "Intro", "MainMenu", "CharacterSelect", "Loading", and "Game".
On the one hand, it totally makes sense to separate these into a state system. After all, they are disparate and would otherwise need to be in a large switch statement, which is obviously messy; and they certainly are well represented by a state system. But at the same time, I look at the "Game" state and wonder if there's something wrong about this state system approach. Because it's like the elephant in the room; it's HUGE and obvious but nobody questions the game state system approach.
It seems silly to me that "Game" is put on the same level as "Main Menu". Yet there isn't a way to break up the "Game" state.
Is a game state system the best way to go? Is there some different, better technique to managing, well, the "game state"? Is it okay to have an intro state which draws a movie and listens for enter, and then a loading state which loops on the resource manager, and then the game state which does practically everything? Doesn't this seem sort of unbalanced to you, too? Am I missing something?
Answer
I think you're just arguing semantics here. It's called Game State because it behaves like a Finite State Machine, with a finite number of states and transitions between them. The 'Game' in 'Game State System' refers to the overall system, with 'Loading', 'MainMenu' etc being states of the game. These could easily be called 'scenes' or 'screens' or 'levels'. Its just semantics.
I'm not sure that a strict FSM applies anymore. In my implementations I call states 'Screens' and allow them to be stackable - ie. screens can be drawn on top of other screens, controlling whether or not screens below them are updated or drawn. In this way, I can have multiple screens active at the same time with self-contained logic and code specific to that screen, without having to worry about any other screen.
A Pause screen, for example, could be opened on top of my main gameplay screen that disallows updates, but allows drawing below itself. A character inventory screen could allow both drawing and updates - so the game keeps playing while you're working in your inventory.
No comments:
Post a Comment