The menu in the game is almost the same as the menu in any application - it is a set of GUI elements with behaviors attached to them. This refers to whether you have a specific menu state or not.
There are several reasons why games have different menu states. One of them is that the game menus are dated before we had usable libraries of graphical user interfaces for games, and most of these menus will simply be collections of sprites and some hard-coded routines for processing mouse clicks. Another thing is that games often require very different input processing during the game, which is necessary during the menu, and therefore it is often easier to have completely separate procedures that process them.
But in fact, there is no need for a separate state of the game in the menu. Your game usually has a graphical interface, some visible elements, some invisible. To open the menu, you simply create or display the necessary items. You may also need to pause the game at this point. (Or not, if it works on the network.) If the game is not already started, it doesn’t matter. Typically, your system will be a much less simplified version of this:
The last 2 steps can be combined if your GUI system is adequate.
Although I do not always follow my advice, I think that there is rarely a good reason to have an excellent top-level state machine for the game. There are a small number of objects that exist in a small number of permutations, and you just need to update and display them all.
source share