Just wondering if someone can advise on how to structure something like Game Menu. I was googling and did not find anything useful. I am coding a little game and Menu part with few sections like START GAME - SELECT LEVEL - SETTINGS (SOUND, MUSIC AND VIBRATION ON/OF) - CREDITS - EXIT.
And just menu alone seems to have tones of code. I have my state machine working but it seems every subsection of the menu has its own state sort if and duplicate code.
Any tips or links to material how to organize code like that would be highly appreciated.
Could you post your general structure? You should only need a single state machine for the entire menu tree.
I've found that coroutines are very useful when modelling anything UI-related. In particular, they obviate the need to explicitly use state machines, making the code much, much more readable and maintainable. You should take a look at boost::coroutine.
It does the job perfectly. I have Default state (Loading Engine Logo and stuff), Logo State, (Loading Game Logos, Videos, etc.), Menu State (All menu elements), Game State.
So the Menu state is what I am working on right now. So I have State for each Button in the menu right now and it looks like a lot of repeating code like SWITCH statements, position of the Menu (which button is selected), etc. And this is done for Every SubMenu.
So just looking for a better way. Don't want to use Boost at the moment.