Game Development Reference
In-Depth Information
Defining states
In all implementations, we start with a collection of states: these define both what condi-
tions/states are in the game and what we do when that state changes.
These states describe both what can happen when that state is active and what other poten-
tial states could result in an action from the current state. If we take the example from Un-
ityGems, which describes a simple case using a television(TV), we would end up with the
states listed in the following table:
State
Description
Actions
TV off
No activity is present and nothing is displayed.
The power button turns the TV on.
The power button turns the TV off.
The up button selects the previous channel.
TV on
The TV displays images and plays sound.
The down button selects the next channel.
The menu button displays the menu.
The power button turns the TV off.
The menu button turns the TV on (menu hid-
den).
Menu dis-
played
The TV displays the menu, overlaying the normal dis-
play.
The up button highlights the previous menu
item.
The down button highlights the next menu
item.
The ok button activates the menu item.
So from each individual state, there are a number of options; in some cases, the same ac-
tion will lead to the same result (such as the power button), some actions will do different
things based on what the current state is (such as the up and down buttons).
It's important to note that in any game, you will likely use many state systems, from
menus to in-game controls and AI.
Search WWH ::




Custom Search