Game Development Reference
In-Depth Information
Figure 10.1 Sample console game menu flow.
One way to ensure menu flow can always return to the base menu is by utilizing
the stack data structure. The “top” element on the stack is the currently active
menu item, and going to a new menu involves pushing that menu onto the stack.
Returning to the previous menu involves popping the current menu off the stack.
This can be further modified so that multiple menus can be visible at once—for
example, a dialog box can appear on top of a particular menu if there's a need to
accept/reject a request. In order to do this, the menus would need to be rendered
from the bottom to the top of the stack.
To store all the menus in one stack, you will need some sort of base class from
which all menus derive. This base class may store information such as the title of
the menu and a linked list ofbuttons (orsub-elements that the menu has). Iused an
approach similar to this to implement the menu system for Tony Hawk's Project
8 , and it's also the approach that's used for the overall UI in Chapter 14 's tower
defense game. One aspect of this system that's not quite a standard stack is the
Search WWH ::




Custom Search